###########################
### PANDEMICS AND POLITICAL DEVELOPMENT
### THE ELECTORAL LEGACY OF THE BLACK DEATH IN GERMANY
### WORLD POLITICS, VOL. 73, NO. 3 (JULY 2021)
### REPLICATION FILE OF THE EMPIRICAL ANALYSIS
### DANIEL W. GINGERICH & JAN P. VOGLER
###########################

###########################
### REPLICATION FILES PART 1
### IMPERIAL GERMANY
###########################

###########################
### INSTALL REQUIRED PACKAGES
###########################

install.packages("readstata13")
install.packages("geosphere")
install.packages("multiwayvcov")
install.packages("lmtest")
install.packages("AER")
install.packages("ggplot2")
install.packages("egg")



###########################
### DATA MANAGEMENT
###########################

###########################
### DATA ON ELECTORAL OUTCOMES IN IMPERIAL GERMANY
### BY SPERBER (1997)
### DISTRICT NAMES ADOPTED FROM ZIBLATT (2009) (MODIFIED AND CORRECTED)
###########################

data_outcomes=read.csv("data_imp_outcomes.csv", stringsAsFactors=F)



###########################
### DATA ON CONTROL VARIABLES
###########################

data_control_var=read.csv("data_imp_control_var.csv", stringsAsFactors=F)



###########################
### DATA ON ELECTORAL DISTRICT GEOLOCATION
###########################

data_district_geoloc=read.csv("data_imp_district_geoloc.csv", stringsAsFactors=F)



###########################
### DATA ON QUASI-RANDOM SPATIAL FIXED EFFECTS
###########################

data_qr_spfe=read.csv("data_imp_qr_spfe.csv", stringsAsFactors=F)



###########################
### DATA ON PRE-TREATMENT SPATIAL FIXED EFFECTS
### BY NUESSLI & NUESSLI (2008)
###########################

data_pre_tr_spfe=read.csv("data_imp_pre_tr_spfe.csv", stringsAsFactors=F)



###########################
### DATA ON
### (1) DISPUTED ELECTIONS
### (2) LANDHOLDING INEQUALITY
### (3) ADDITIONAL CONTROL VARIABLES
### BY ARSENSCHEK & ZIBLATT (2010) AND ZIBLATT (2009)
###########################

library(readstata13)

data_disputes=read.dta13("Arsenschek_Ziblatt.dta")
data_disputes$DISTRICT=data_disputes$constituency
data_disputes$NetDisputes=as.numeric(data_disputes$NetDisputes)
data_disputes=data_disputes[-c(399,398),]

data_landinequality=read.dta13("Land Inequality Reichstag Constituencies 1895.dta")
data_landinequality$DISTRICT=data_landinequality$reichstag_constituency

data_add_control_var=read.dta13("APSRReplicationZiblatt.dta")
data_add_control_var$DISTRICT=data_add_control_var$district
data_add_control_var$pop=data_add_control_var$pop/1000

data_add_control_var=data_add_control_var[which(data_add_control_var$time==0),]

data_add_control_var=data_add_control_var[,c("DISTRICT","ag1","pop")]



###########################
### CORRECT WRONG ELECTORAL DISTRICT NAMES
###########################

### DATA_DISPUTES

data_disputes$DISTRICT[which(data_disputes$DISTRICT=="AIBACH")]="AICHACH"
data_disputes$DISTRICT[which(data_disputes$DISTRICT=="GLATZ-HUBELSCHW")]="GLATZ-HABELSCHW"
data_disputes$DISTRICT[which(data_disputes$DISTRICT=="MERSERITZ-BOMST")]="MESERITZ-BOMST"
data_disputes$DISTRICT[which(data_disputes$DISTRICT=="NEUSTADT-WALDRAAB")]="NEUSTADT-WALDNAAB"
data_disputes$DISTRICT[which(data_disputes$DISTRICT=="WARTENBG-OLS")]="WARTENBG-OELS"

### DATA_LANDINEQUALITY

data_landinequality$DISTRICT[which(data_landinequality$DISTRICT=="AIBACH")]="AICHACH"
data_landinequality$DISTRICT[which(data_landinequality$DISTRICT=="GLATZ-HUBELSCHW")]="GLATZ-HABELSCHW"
data_landinequality$DISTRICT[which(data_landinequality$DISTRICT=="MERSERITZ-BOMST")]="MESERITZ-BOMST"
data_landinequality$DISTRICT[which(data_landinequality$DISTRICT=="NEUSTADT-WALDRAAB")]="NEUSTADT-WALDNAAB"
data_landinequality$DISTRICT[which(data_landinequality$DISTRICT=="WARTENBG-OLS")]="WARTENBG-OELS"

### DATA_ADD_CONTROL_VAR

data_add_control_var$DISTRICT[which(data_add_control_var$DISTRICT=="AIBACH")]="AICHACH"
data_add_control_var$DISTRICT[which(data_add_control_var$DISTRICT=="GLATZ-HUBELSCHW")]="GLATZ-HABELSCHW"
data_add_control_var$DISTRICT[which(data_add_control_var$DISTRICT=="MERSERITZ-BOMST")]="MESERITZ-BOMST"
data_add_control_var$DISTRICT[which(data_add_control_var$DISTRICT=="NEUSTADT-WALDRAAB")]="NEUSTADT-WALDNAAB"
data_add_control_var$DISTRICT[which(data_add_control_var$DISTRICT=="WARTENBG-OLS")]="WARTENBG-OELS"



###########################
### MERGE DATASETS FOR ANALYSIS
###########################

data_analysis_1871_fin=merge(data_outcomes,data_control_var, by="DISTRICT")

data_analysis_1871_fin=merge(data_analysis_1871_fin,data_disputes, by="DISTRICT")

data_analysis_1871_fin=merge(data_analysis_1871_fin,data_landinequality, by="DISTRICT")

data_analysis_1871_fin=merge(data_analysis_1871_fin,data_add_control_var, by="DISTRICT")



###########################
### DATA ON BLACK DEATH OUTBREAKS
### BY JEDWAB ET AL. (2019)
###########################

data_bd_outbreaks=read.csv("data_imp_bd_outbreaks.csv", stringsAsFactors=F)



###########################
### CALCULATING BDEI SCORES
###########################

###########################
### STANDARD VERSION
###########################

###########################
### COMPUTE THE GLOBAL MAXIMUM DISTANCE
###########################

library(geosphere)
data_geoloc_01=data_district_geoloc
max_store=rep(NA,length(data_geoloc_01$DISTRICT))
for (j in 1:length(data_geoloc_01$DISTRICT)){
  store=rep(NA,length(data_bd_outbreaks$int))
  for (i in 1:length(data_bd_outbreaks$int)){
    store[i]=distm(c(data_geoloc_01$Long[j], data_geoloc_01$Lat[j]), c(data_bd_outbreaks$longitude[i], data_bd_outbreaks$latitude[i]), fun = distHaversine)
    max_store[j]=max(store)
  }
}
max_dist=max(max_store)



###########################
### COMPUTE BLACK DEATH EXPOSURE INTENSITY SCORE (V1-5)
###########################

for (j in 1:length(data_geoloc_01$DISTRICT)){
  store=rep(NA,length(data_bd_outbreaks$int))
  for (i in 1:length(data_bd_outbreaks$int)){
    store[i]=distm(c(data_geoloc_01$Long[j], data_geoloc_01$Lat[j]), c(data_bd_outbreaks$longitude[i], data_bd_outbreaks$latitude[i]), fun = distHaversine)
    data_geoloc_01$BDEI_score[j]=sum(data_bd_outbreaks$int*(1-store/max_dist)^3)
    data_geoloc_01$BDEI_score2[j]=sum(data_bd_outbreaks$int*(1-store/max_dist)^6)
    data_geoloc_01$BDEI_score3[j]=sum(data_bd_outbreaks$int*(1-store/max_dist)^9)
    data_geoloc_01$BDEI_score4[j]=sum(data_bd_outbreaks$int*(1-store/max_dist)^12)
    data_geoloc_01$BDEI_score5[j]=sum(data_bd_outbreaks$int*(1-store/max_dist)^15)
  }
}



###########################
### MERGE WITH MAIN DATASET
###########################

data_geoloc_01=data_geoloc_01[,c("DISTRICT","BDEI_score","BDEI_score2","BDEI_score3","BDEI_score4","BDEI_score5")]
data_analysis_1871_fin=merge(data_analysis_1871_fin,data_geoloc_01, by="DISTRICT")



###########################
### ALTERNATIVE BDEI MEASURE WITHOUT OBSERVATIONS FROM THE BRITISH ISLES
###########################

data_geoloc_02=data_district_geoloc

data_bd_outbreaks_alt=data_bd_outbreaks
data_bd_outbreaks_alt=data_bd_outbreaks_alt[-which(data_bd_outbreaks_alt$countryname=="United Kingdom" | data_bd_outbreaks_alt$countryname=="Ireland"),]



###########################
### COMPUTE THE GLOBAL MAXIMUM DISTANCE
###########################

max_store=rep(NA,length(data_geoloc_02$DISTRICT))
for (j in 1:length(data_geoloc_02$DISTRICT)){
  store=rep(NA,length(data_bd_outbreaks_alt$int))
  for (i in 1:length(data_bd_outbreaks_alt$int)){
    store[i]=distm(c(data_geoloc_02$Long[j], data_geoloc_02$Lat[j]), c(data_bd_outbreaks_alt$longitude[i], data_bd_outbreaks_alt$latitude[i]), fun = distHaversine)
    max_store[j]=max(store)
  }
}
max_dist=max(max_store)



###########################
### COMPUTE BLACK DEATH EXPOSURE INTENSITY SCORE (V1-5) (ALT. VERSION)
###########################

for (j in 1:length(data_geoloc_02$DISTRICT)){
  store=rep(NA,length(data_bd_outbreaks_alt$int))
  for (i in 1:length(data_bd_outbreaks_alt$int)){
    store[i]=distm(c(data_geoloc_02$Long[j], data_geoloc_02$Lat[j]), c(data_bd_outbreaks_alt$longitude[i], data_bd_outbreaks_alt$latitude[i]), fun = distHaversine)
    data_geoloc_02$BDEI_score_alt[j]=sum(data_bd_outbreaks_alt$int*(1-store/max_dist)^3)
    data_geoloc_02$BDEI_score_alt2[j]=sum(data_bd_outbreaks_alt$int*(1-store/max_dist)^6)
    data_geoloc_02$BDEI_score_alt3[j]=sum(data_bd_outbreaks_alt$int*(1-store/max_dist)^9)
    data_geoloc_02$BDEI_score_alt4[j]=sum(data_bd_outbreaks_alt$int*(1-store/max_dist)^12)
    data_geoloc_02$BDEI_score_alt5[j]=sum(data_bd_outbreaks_alt$int*(1-store/max_dist)^15)
  }
}



###########################
### MERGE WITH MAIN DATASET
###########################

data_geoloc_02=data_geoloc_02[,c("DISTRICT","BDEI_score_alt","BDEI_score_alt2","BDEI_score_alt3","BDEI_score_alt4","BDEI_score_alt5")]
data_analysis_1871_fin=merge(data_analysis_1871_fin,data_geoloc_02, by=c("DISTRICT"))



###########################
### ALTERNATIVE BDEI MEASURE WITH ONLY NEIGHBORING REGIONS
###########################

data_geoloc_03=data_district_geoloc
data_bd_outbreaks_neighb=data_bd_outbreaks
data_bd_outbreaks_neighb=data_bd_outbreaks_neighb[which(data_bd_outbreaks_neighb$countryname=="Austria" | data_bd_outbreaks_neighb$countryname=="Belgium" | data_bd_outbreaks_neighb$countryname=="Czech Republic" | data_bd_outbreaks_neighb$countryname=="France" | data_bd_outbreaks_neighb$countryname=="Germany" | data_bd_outbreaks_neighb$countryname=="Switzerland"),]



###########################
### COMPUTE THE GLOBAL MAXIMUM DISTANCE
###########################

max_store=rep(NA,length(data_geoloc_03$DISTRICT))
for (j in 1:length(data_geoloc_03$DISTRICT)){
  store=rep(NA,length(data_bd_outbreaks_neighb$int))
  for (i in 1:length(data_bd_outbreaks_neighb$int)){
    store[i]=distm(c(data_geoloc_03$Long[j], data_geoloc_03$Lat[j]), c(data_bd_outbreaks_neighb$longitude[i], data_bd_outbreaks_neighb$latitude[i]), fun = distHaversine)
    max_store[j]=max(store)
  }
}
max_dist=max(max_store)



###########################
### COMPUTE BLACK DEATH EXPOSURE INTENSITY SCORE (V1-5) (ONLY NEIGHBORING REGIONS)
###########################

for (j in 1:length(data_geoloc_03$DISTRICT)){
  store=rep(NA,length(data_bd_outbreaks_neighb$int))
  for (i in 1:length(data_bd_outbreaks_neighb$int)){
    store[i]=distm(c(data_geoloc_03$Long[j], data_geoloc_03$Lat[j]), c(data_bd_outbreaks_neighb$longitude[i], data_bd_outbreaks_neighb$latitude[i]), fun = distHaversine)
    data_geoloc_03$BDEI_score_neighb[j]=sum(data_bd_outbreaks_neighb$int*(1-store/max_dist)^3)
    data_geoloc_03$BDEI_score_neighb2[j]=sum(data_bd_outbreaks_neighb$int*(1-store/max_dist)^6)
    data_geoloc_03$BDEI_score_neighb3[j]=sum(data_bd_outbreaks_neighb$int*(1-store/max_dist)^9)
    data_geoloc_03$BDEI_score_neighb4[j]=sum(data_bd_outbreaks_neighb$int*(1-store/max_dist)^12)
    data_geoloc_03$BDEI_score_neighb5[j]=sum(data_bd_outbreaks_neighb$int*(1-store/max_dist)^15)
  }
}



###########################
### MERGE WITH MAIN DATASET
###########################

data_geoloc_03=data_geoloc_03[,c("DISTRICT","BDEI_score_neighb","BDEI_score_neighb2","BDEI_score_neighb3","BDEI_score_neighb4","BDEI_score_neighb5")]
data_analysis_1871_fin=merge(data_analysis_1871_fin,data_geoloc_03, by=c("DISTRICT"), all.x=T)



###########################
#### ALTERNATIVE BDEI MEASURE WITH PREDICTED BLACK DEATH SEVERITY BASED ON THE TIMING OF THE FIRST OUTBREAK
###########################

data_geoloc_04=data_district_geoloc

data_bd_outbreaks_pred=data_bd_outbreaks
data_bd_outbreaks_pred=data_bd_outbreaks_pred[-which(is.na(data_bd_outbreaks_pred$start_month)),]

data_bd_outbreaks_pred$q1=0
data_bd_outbreaks_pred$q2=0
data_bd_outbreaks_pred$q3=0

data_bd_outbreaks_pred$q1[which(data_bd_outbreaks_pred$start_month >= 1 & data_bd_outbreaks_pred$start_month <= 3)]=1
data_bd_outbreaks_pred$q2[which(data_bd_outbreaks_pred$start_month >= 4 & data_bd_outbreaks_pred$start_month <= 6)]=1
data_bd_outbreaks_pred$q3[which(data_bd_outbreaks_pred$start_month >= 7 & data_bd_outbreaks_pred$start_month <= 9)]=1

lm_predict=lm(int ~ q1 + q2 + q3 + as.factor(start_year), data=data_bd_outbreaks_pred)
summary(lm_predict)

data_bd_outbreaks_pred$int_pred=predict(lm_predict, newdata=data_bd_outbreaks_pred)



###########################
### COMPUTE THE GLOBAL MAXIMUM DISTANCE
###########################

max_store=rep(NA,length(data_geoloc_04$DISTRICT))
for (j in 1:length(data_geoloc_04$DISTRICT)){
  store=rep(NA,length(data_bd_outbreaks_pred$int_pred))
  for (i in 1:length(data_bd_outbreaks_pred$int_pred)){
    store[i]=distm(c(data_geoloc_04$Long[j], data_geoloc_04$Lat[j]), c(data_bd_outbreaks_pred$longitude[i], data_bd_outbreaks_pred$latitude[i]), fun = distHaversine)
    max_store[j]=max(store)
  }
}
max_dist=max(max_store)



###########################
### COMPUTE BLACK DEATH EXPOSURE INTENSITY SCORE (V1-5) (2SLS)
###########################

for (j in 1:length(data_geoloc_04$DISTRICT)){
  store=rep(NA,length(data_bd_outbreaks_pred$int_pred))
  for (i in 1:length(data_bd_outbreaks_pred$int_pred)){
    store[i]=distm(c(data_geoloc_04$Long[j], data_geoloc_04$Lat[j]), c(data_bd_outbreaks_pred$longitude[i], data_bd_outbreaks_pred$latitude[i]), fun = distHaversine)
    data_geoloc_04$BDEI_score_pred[j]=sum(data_bd_outbreaks_pred$int_pred*(1-store/max_dist)^3)
    data_geoloc_04$BDEI_score_pred2[j]=sum(data_bd_outbreaks_pred$int_pred*(1-store/max_dist)^6)
    data_geoloc_04$BDEI_score_pred3[j]=sum(data_bd_outbreaks_pred$int_pred*(1-store/max_dist)^9)
    data_geoloc_04$BDEI_score_pred4[j]=sum(data_bd_outbreaks_pred$int_pred*(1-store/max_dist)^12)
    data_geoloc_04$BDEI_score_pred5[j]=sum(data_bd_outbreaks_pred$int_pred*(1-store/max_dist)^15)
  }
}



###########################
### MERGE WITH MAIN DATASET
###########################

data_geoloc_04=data_geoloc_04[,c("DISTRICT","BDEI_score_pred","BDEI_score_pred2","BDEI_score_pred3","BDEI_score_pred4","BDEI_score_pred5")]
data_analysis_1871_fin=merge(data_analysis_1871_fin,data_geoloc_04, by=c("DISTRICT"), all.x=T)



###########################
### ALTERNATIVE BDEI MEASURE BASED ON ANOTHER DATASET OF BLACK DEATH OUTBREAKS
### BY BUENTGEN ET AL. (2012)
###########################

data_geoloc_05=data_district_geoloc
data_bd_outbreaks_novel=read.csv("Historical_plague_outbreaks.csv", stringsAsFactors = F)
data_bd_outbreaks_novel=data_bd_outbreaks_novel[which(data_bd_outbreaks_novel$Year_of_Outbreak>1346 & data_bd_outbreaks_novel$Year_of_Outbreak<1353),]
data_bd_outbreaks_novel$int=1

# CORRECT LATITUDE AND LONGITUDE

data_bd_outbreaks_novel$Lat=data_bd_outbreaks_novel$Lon_WGS84
data_bd_outbreaks_novel$Long=data_bd_outbreaks_novel$Lat_WGS84



###########################
### COMPUTE THE GLOBAL MAXIMUM DISTANCE
###########################

max_store=rep(NA,length(data_geoloc_05$DISTRICT))
for (j in 1:length(data_geoloc_05$DISTRICT)){
  store=rep(NA,length(data_bd_outbreaks_novel$int))
  for (i in 1:length(data_bd_outbreaks_novel$int)){
    store[i]=distm(c(data_geoloc_05$Long[j], data_geoloc_05$Lat[j]), c(data_bd_outbreaks_novel$Long[i], data_bd_outbreaks_novel$Lat[i]), fun = distHaversine)
    max_store[j]=max(store)
  }
}
max_dist=max(max_store)



###########################
### COMPUTE BLACK DEATH EXPOSURE INTENSITY SCORE (V1-5) (BUENTGEN ET AL. 2012 DATA)
###########################

for (j in 1:length(data_geoloc_05$DISTRICT)){
  store=rep(NA,length(data_bd_outbreaks_novel$int))
  for (i in 1:length(data_bd_outbreaks_novel$int)){
    store[i]=distm(c(data_geoloc_05$Long[j], data_geoloc_05$Lat[j]), c(data_bd_outbreaks_novel$Long[i], data_bd_outbreaks_novel$Lat[i]), fun = distHaversine)
    data_geoloc_05$BDEI_score_novel[j]=sum(data_bd_outbreaks_novel$int*(1-store/max_dist)^3)
    data_geoloc_05$BDEI_score_novel2[j]=sum(data_bd_outbreaks_novel$int*(1-store/max_dist)^6)
    data_geoloc_05$BDEI_score_novel3[j]=sum(data_bd_outbreaks_novel$int*(1-store/max_dist)^9)
    data_geoloc_05$BDEI_score_novel4[j]=sum(data_bd_outbreaks_novel$int*(1-store/max_dist)^12)
    data_geoloc_05$BDEI_score_novel5[j]=sum(data_bd_outbreaks_novel$int*(1-store/max_dist)^15)
  }
}



###########################
### MERGE WITH MAIN DATASET
###########################

data_geoloc_05=data_geoloc_05[,c("DISTRICT","BDEI_score_novel","BDEI_score_novel2","BDEI_score_novel3","BDEI_score_novel4","BDEI_score_novel5")]
data_analysis_1871_fin=merge(data_analysis_1871_fin,data_geoloc_05, by=c("DISTRICT"), all.x=T)



###########################
### ALTERNATIVE BDEI MEASURE BASED ON ANOTHER DATASET OF BLACK DEATH OUTBREAKS
### BY SCHMID ET AL. (2015)
###########################

data_geoloc_06=data_district_geoloc
data_bd_outbreaks_newdata=read.csv("pnas2015_utf8.csv", encoding="UTF-8", stringsAsFactors = F)
data_bd_outbreaks_newdata=data_bd_outbreaks_newdata[which(data_bd_outbreaks_newdata$year>1346 & data_bd_outbreaks_newdata$year<1353),]
data_bd_outbreaks_newdata$int=1



###########################
### COMPUTE THE GLOBAL MAXIMUM DISTANCE
###########################

max_store=rep(NA,length(data_geoloc_06$DISTRICT))
for (j in 1:length(data_geoloc_06$DISTRICT)){
  store=rep(NA,length(data_bd_outbreaks_newdata$int))
  for (i in 1:length(data_bd_outbreaks_newdata$int)){
    store[i]=distm(c(data_geoloc_06$Long[j], data_geoloc_06$Lat[j]), c(data_bd_outbreaks_newdata$lon[i], data_bd_outbreaks_newdata$lat[i]), fun = distHaversine)
    max_store[j]=max(store)
  }
}
max_dist=max(max_store)



###########################
### COMPUTE BLACK DEATH EXPOSURE INTENSITY SCORE (V1-5) (SCHMID ET AL. 2015 DATA)
###########################

for (j in 1:length(data_geoloc_06$DISTRICT)){
  store=rep(NA,length(data_bd_outbreaks_newdata$int))
  for (i in 1:length(data_bd_outbreaks_newdata$int)){
    store[i]=distm(c(data_geoloc_06$Long[j], data_geoloc_06$Lat[j]), c(data_bd_outbreaks_newdata$lon[i], data_bd_outbreaks_newdata$lat[i]), fun = distHaversine)
    data_geoloc_06$BDEI_score_newdata[j]=sum(data_bd_outbreaks_newdata$int*(1-store/max_dist)^3)
    data_geoloc_06$BDEI_score_newdata2[j]=sum(data_bd_outbreaks_newdata$int*(1-store/max_dist)^6)
    data_geoloc_06$BDEI_score_newdata3[j]=sum(data_bd_outbreaks_newdata$int*(1-store/max_dist)^9)
    data_geoloc_06$BDEI_score_newdata4[j]=sum(data_bd_outbreaks_newdata$int*(1-store/max_dist)^12)
    data_geoloc_06$BDEI_score_newdata5[j]=sum(data_bd_outbreaks_newdata$int*(1-store/max_dist)^15)
  }
}



###########################
### MERGE WITH MAIN DATASET
###########################

data_geoloc_06=data_geoloc_06[,c("DISTRICT","BDEI_score_newdata","BDEI_score_newdata2","BDEI_score_newdata3","BDEI_score_newdata4","BDEI_score_newdata5")]
data_analysis_1871_fin=merge(data_analysis_1871_fin,data_geoloc_06, by=c("DISTRICT"), all.x=T)



###########################
### ALTERNATIVE BDEI MEASURE BASED ON POPULATION WEIGHTS
###########################

data_geoloc_07=data_district_geoloc
data_bd_outbreaks_weight=data_bd_outbreaks[-which(is.na(data_bd_outbreaks$preplaguepop)),]
max_log_pop=max(log(data_bd_outbreaks_weight$preplaguepop), na.rm=T)



###########################
### COMPUTE THE GLOBAL MAXIMUM DISTANCE
###########################

max_store=rep(NA,length(data_geoloc_07$DISTRICT))
for (j in 1:length(data_geoloc_07$DISTRICT)){
  store=rep(NA,length(data_bd_outbreaks_weight$int))
  for (i in 1:length(data_bd_outbreaks_weight$int)){
    store[i]=distm(c(data_geoloc_07$Long[j], data_geoloc_07$Lat[j]), c(data_bd_outbreaks_weight$longitude[i], data_bd_outbreaks_weight$latitude[i]), fun = distHaversine)
    max_store[j]=max(store)
  }
}
max_dist=max(max_store)



###########################
### COMPUTE BLACK DEATH EXPOSURE INTENSITY SCORE (V1-5) (WEIGHTED BY POPULATION SIZE)
###########################

for (j in 1:length(data_geoloc_07$DISTRICT)){
  store=rep(NA,length(data_bd_outbreaks_weight$int))
  for (i in 1:length(data_bd_outbreaks_weight$int)){
    store[i]=distm(c(data_geoloc_07$Long[j], data_geoloc_07$Lat[j]), c(data_bd_outbreaks_weight$longitude[i], data_bd_outbreaks_weight$latitude[i]), fun = distHaversine)
    data_geoloc_07$BDEI_score_weight[j]=sum(data_bd_outbreaks_weight$int*(log(data_bd_outbreaks_weight$preplaguepop)/max_log_pop)*(1-store/max_dist)^3)
    data_geoloc_07$BDEI_score_weight2[j]=sum(data_bd_outbreaks_weight$int*(log(data_bd_outbreaks_weight$preplaguepop)/max_log_pop)*(1-store/max_dist)^6)
    data_geoloc_07$BDEI_score_weight3[j]=sum(data_bd_outbreaks_weight$int*(log(data_bd_outbreaks_weight$preplaguepop)/max_log_pop)*(1-store/max_dist)^9)
    data_geoloc_07$BDEI_score_weight4[j]=sum(data_bd_outbreaks_weight$int*(log(data_bd_outbreaks_weight$preplaguepop)/max_log_pop)*(1-store/max_dist)^12)
    data_geoloc_07$BDEI_score_weight5[j]=sum(data_bd_outbreaks_weight$int*(log(data_bd_outbreaks_weight$preplaguepop)/max_log_pop)*(1-store/max_dist)^15)
  }
}



###########################
### MERGE WITH MAIN DATASET
###########################

data_geoloc_07=data_geoloc_07[,c("DISTRICT","BDEI_score_weight","BDEI_score_weight2","BDEI_score_weight3","BDEI_score_weight4","BDEI_score_weight5")]
data_analysis_1871_fin=merge(data_analysis_1871_fin,data_geoloc_07, by=c("DISTRICT"), all.x=T)



###########################
### STANDARDIZE BLACK DEATH EXPOSURE INTENSITY SCORES (V1-5)
### ALL VERSIONS
###########################

data_analysis_1871_fin$BDEI_score=scale(data_analysis_1871_fin$BDEI_score)[,1]
data_analysis_1871_fin$BDEI_score2=scale(data_analysis_1871_fin$BDEI_score2)[,1]
data_analysis_1871_fin$BDEI_score3=scale(data_analysis_1871_fin$BDEI_score3)[,1]
data_analysis_1871_fin$BDEI_score4=scale(data_analysis_1871_fin$BDEI_score4)[,1]
data_analysis_1871_fin$BDEI_score5=scale(data_analysis_1871_fin$BDEI_score5)[,1]

data_analysis_1871_fin$BDEI_score_alt=scale(data_analysis_1871_fin$BDEI_score_alt)[,1]
data_analysis_1871_fin$BDEI_score_alt2=scale(data_analysis_1871_fin$BDEI_score_alt2)[,1]
data_analysis_1871_fin$BDEI_score_alt3=scale(data_analysis_1871_fin$BDEI_score_alt3)[,1]
data_analysis_1871_fin$BDEI_score_alt4=scale(data_analysis_1871_fin$BDEI_score_alt4)[,1]
data_analysis_1871_fin$BDEI_score_alt5=scale(data_analysis_1871_fin$BDEI_score_alt5)[,1]

data_analysis_1871_fin$BDEI_score_pred=scale(data_analysis_1871_fin$BDEI_score_pred)[,1]
data_analysis_1871_fin$BDEI_score_pred2=scale(data_analysis_1871_fin$BDEI_score_pred2)[,1]
data_analysis_1871_fin$BDEI_score_pred3=scale(data_analysis_1871_fin$BDEI_score_pred3)[,1]
data_analysis_1871_fin$BDEI_score_pred4=scale(data_analysis_1871_fin$BDEI_score_pred4)[,1]
data_analysis_1871_fin$BDEI_score_pred5=scale(data_analysis_1871_fin$BDEI_score_pred5)[,1]

data_analysis_1871_fin$BDEI_score_novel=scale(data_analysis_1871_fin$BDEI_score_novel)[,1]
data_analysis_1871_fin$BDEI_score_novel2=scale(data_analysis_1871_fin$BDEI_score_novel2)[,1]
data_analysis_1871_fin$BDEI_score_novel3=scale(data_analysis_1871_fin$BDEI_score_novel3)[,1]
data_analysis_1871_fin$BDEI_score_novel4=scale(data_analysis_1871_fin$BDEI_score_novel4)[,1]
data_analysis_1871_fin$BDEI_score_novel5=scale(data_analysis_1871_fin$BDEI_score_novel5)[,1]

data_analysis_1871_fin$BDEI_score_newdata=scale(data_analysis_1871_fin$BDEI_score_newdata)[,1]
data_analysis_1871_fin$BDEI_score_newdata2=scale(data_analysis_1871_fin$BDEI_score_newdata2)[,1]
data_analysis_1871_fin$BDEI_score_newdata3=scale(data_analysis_1871_fin$BDEI_score_newdata3)[,1]
data_analysis_1871_fin$BDEI_score_newdata4=scale(data_analysis_1871_fin$BDEI_score_newdata4)[,1]
data_analysis_1871_fin$BDEI_score_newdata5=scale(data_analysis_1871_fin$BDEI_score_newdata5)[,1]

data_analysis_1871_fin$BDEI_score_weight=scale(data_analysis_1871_fin$BDEI_score_weight)[,1]
data_analysis_1871_fin$BDEI_score_weight2=scale(data_analysis_1871_fin$BDEI_score_weight2)[,1]
data_analysis_1871_fin$BDEI_score_weight3=scale(data_analysis_1871_fin$BDEI_score_weight3)[,1]
data_analysis_1871_fin$BDEI_score_weight4=scale(data_analysis_1871_fin$BDEI_score_weight4)[,1]
data_analysis_1871_fin$BDEI_score_weight5=scale(data_analysis_1871_fin$BDEI_score_weight5)[,1]

data_analysis_1871_fin$BDEI_score_neighb=scale(data_analysis_1871_fin$BDEI_score_neighb)[,1]
data_analysis_1871_fin$BDEI_score_neighb2=scale(data_analysis_1871_fin$BDEI_score_neighb2)[,1]
data_analysis_1871_fin$BDEI_score_neighb3=scale(data_analysis_1871_fin$BDEI_score_neighb3)[,1]
data_analysis_1871_fin$BDEI_score_neighb4=scale(data_analysis_1871_fin$BDEI_score_neighb4)[,1]
data_analysis_1871_fin$BDEI_score_neighb5=scale(data_analysis_1871_fin$BDEI_score_neighb5)[,1]



###########################
### CREATE A SUBSET OF OBSERVATIONS IN WHICH AT LEAST 33.33% OF ALL WORKERS IN A DISTRICT ARE ENGAGED IN AGRICULTURE
###########################

data_analysis_1871_fin_agric=data_analysis_1871_fin[which(data_analysis_1871_fin$ag1 > 33.33),]



###########################
### CREATE DATASET INCLUDING QUASI-RANDOM SPATIAL FIXED EFFECTS
###########################

data_analysis_1871_fin_qrSPFE=merge(data_analysis_1871_fin,data_qr_spfe, by="DISTRICT", all.x=T)     



###########################
### CREATE DATASET INCLUDING PRE-TREATMENT SPATIAL FIXED EFFECTS
###########################

data_analysis_1871_fin_pretrSPFE=merge(data_analysis_1871_fin,data_pre_tr_spfe, by="DISTRICT", all.x=T) 



###########################
### MAIN EMPIRICAL ANALYSIS IN THE ARTICLE
###########################

###########################
### LANDHOLDING INEQUALITY
### TABLE 1 IN THE ARTICLE
###########################

lm_exp1_an71_landineq=lm(landgini ~ BDEI_score, data=data_analysis_1871_fin)
summary(lm_exp1_an71_landineq)

lm_exp2_an71_landineq=lm(landgini ~ BDEI_score2, data=data_analysis_1871_fin)
summary(lm_exp2_an71_landineq)

lm_exp3_an71_landineq=lm(landgini ~ BDEI_score3, data=data_analysis_1871_fin)
summary(lm_exp3_an71_landineq)

lm_exp4_an71_landineq=lm(landgini ~ BDEI_score4, data=data_analysis_1871_fin)
summary(lm_exp4_an71_landineq)

lm_exp5_an71_landineq=lm(landgini ~ BDEI_score5, data=data_analysis_1871_fin)
summary(lm_exp5_an71_landineq)

lm_exp1_an71_landineq_ctrl=lm(landgini ~ BDEI_score + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp1_an71_landineq_ctrl)

lm_exp2_an71_landineq_ctrl=lm(landgini ~ BDEI_score2 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp2_an71_landineq_ctrl)

lm_exp3_an71_landineq_ctrl=lm(landgini ~ BDEI_score3 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp3_an71_landineq_ctrl)

lm_exp4_an71_landineq_ctrl=lm(landgini ~ BDEI_score4 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp4_an71_landineq_ctrl)

lm_exp5_an71_landineq_ctrl=lm(landgini ~ BDEI_score5 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp5_an71_landineq_ctrl)

# CLUSTERED STANDARD ERRORS

library(multiwayvcov)
library(lmtest)

lm_exp1_an71_landineq.vcovCL=cluster.vcov(lm_exp1_an71_landineq, data_analysis_1871_fin$reg_bez)
lm_exp1_an71_landineq.clse=coeftest(lm_exp1_an71_landineq, lm_exp1_an71_landineq.vcovCL)
lm_exp1_an71_landineq.clse

lm_exp2_an71_landineq.vcovCL=cluster.vcov(lm_exp2_an71_landineq, data_analysis_1871_fin$reg_bez)
lm_exp2_an71_landineq.clse=coeftest(lm_exp2_an71_landineq, lm_exp2_an71_landineq.vcovCL)
lm_exp2_an71_landineq.clse

lm_exp3_an71_landineq.vcovCL=cluster.vcov(lm_exp3_an71_landineq, data_analysis_1871_fin$reg_bez)
lm_exp3_an71_landineq.clse=coeftest(lm_exp3_an71_landineq, lm_exp3_an71_landineq.vcovCL)
lm_exp3_an71_landineq.clse

lm_exp4_an71_landineq.vcovCL=cluster.vcov(lm_exp4_an71_landineq, data_analysis_1871_fin$reg_bez)
lm_exp4_an71_landineq.clse=coeftest(lm_exp4_an71_landineq, lm_exp4_an71_landineq.vcovCL)
lm_exp4_an71_landineq.clse

lm_exp5_an71_landineq.vcovCL=cluster.vcov(lm_exp5_an71_landineq, data_analysis_1871_fin$reg_bez)
lm_exp5_an71_landineq.clse=coeftest(lm_exp5_an71_landineq, lm_exp5_an71_landineq.vcovCL)
lm_exp5_an71_landineq.clse

lm_exp1_an71_landineq_ctrl.vcovCL=cluster.vcov(lm_exp1_an71_landineq_ctrl, data_analysis_1871_fin$reg_bez)
lm_exp1_an71_landineq_ctrl.clse=coeftest(lm_exp1_an71_landineq_ctrl, lm_exp1_an71_landineq_ctrl.vcovCL)
lm_exp1_an71_landineq_ctrl.clse

lm_exp2_an71_landineq_ctrl.vcovCL=cluster.vcov(lm_exp2_an71_landineq_ctrl, data_analysis_1871_fin$reg_bez)
lm_exp2_an71_landineq_ctrl.clse=coeftest(lm_exp2_an71_landineq_ctrl, lm_exp2_an71_landineq_ctrl.vcovCL)
lm_exp2_an71_landineq_ctrl.clse

lm_exp3_an71_landineq_ctrl.vcovCL=cluster.vcov(lm_exp3_an71_landineq_ctrl, data_analysis_1871_fin$reg_bez)
lm_exp3_an71_landineq_ctrl.clse=coeftest(lm_exp3_an71_landineq_ctrl, lm_exp3_an71_landineq_ctrl.vcovCL)
lm_exp3_an71_landineq_ctrl.clse

lm_exp4_an71_landineq_ctrl.vcovCL=cluster.vcov(lm_exp4_an71_landineq_ctrl, data_analysis_1871_fin$reg_bez)
lm_exp4_an71_landineq_ctrl.clse=coeftest(lm_exp4_an71_landineq_ctrl, lm_exp4_an71_landineq_ctrl.vcovCL)
lm_exp4_an71_landineq_ctrl.clse

lm_exp5_an71_landineq_ctrl.vcovCL=cluster.vcov(lm_exp5_an71_landineq_ctrl, data_analysis_1871_fin$reg_bez)
lm_exp5_an71_landineq_ctrl.clse=coeftest(lm_exp5_an71_landineq_ctrl, lm_exp5_an71_landineq_ctrl.vcovCL)
lm_exp5_an71_landineq_ctrl.clse



###########################
### CONSERVATIVE PARTY VOTE SHARE
### TABLE 2 IN THE ARTICLE
###########################

lm_exp1_an71_consvotes=lm(votes_cons_share_1871 ~ BDEI_score, data=data_analysis_1871_fin)
summary(lm_exp1_an71_consvotes)

lm_exp2_an71_consvotes=lm(votes_cons_share_1871 ~ BDEI_score2, data=data_analysis_1871_fin)
summary(lm_exp2_an71_consvotes)

lm_exp3_an71_consvotes=lm(votes_cons_share_1871 ~ BDEI_score3, data=data_analysis_1871_fin)
summary(lm_exp3_an71_consvotes)

lm_exp4_an71_consvotes=lm(votes_cons_share_1871 ~ BDEI_score4, data=data_analysis_1871_fin)
summary(lm_exp4_an71_consvotes)

lm_exp5_an71_consvotes=lm(votes_cons_share_1871 ~ BDEI_score5, data=data_analysis_1871_fin)
summary(lm_exp5_an71_consvotes)

lm_exp1_an71_consvotes_ctrl=lm(votes_cons_share_1871 ~ BDEI_score + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp1_an71_consvotes_ctrl)

lm_exp2_an71_consvotes_ctrl=lm(votes_cons_share_1871 ~ BDEI_score2 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp2_an71_consvotes_ctrl)

lm_exp3_an71_consvotes_ctrl=lm(votes_cons_share_1871 ~ BDEI_score3 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp3_an71_consvotes_ctrl)

lm_exp4_an71_consvotes_ctrl=lm(votes_cons_share_1871 ~ BDEI_score4 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp4_an71_consvotes_ctrl)

lm_exp5_an71_consvotes_ctrl=lm(votes_cons_share_1871 ~ BDEI_score5 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp5_an71_consvotes_ctrl)

### CLUSTERED STANDARD ERRORS

lm_exp1_an71_consvotes.vcovCL=cluster.vcov(lm_exp1_an71_consvotes, data_analysis_1871_fin$reg_bez)
lm_exp1_an71_consvotes.clse=coeftest(lm_exp1_an71_consvotes, lm_exp1_an71_consvotes.vcovCL)
lm_exp1_an71_consvotes.clse

lm_exp2_an71_consvotes.vcovCL=cluster.vcov(lm_exp2_an71_consvotes, data_analysis_1871_fin$reg_bez)
lm_exp2_an71_consvotes.clse=coeftest(lm_exp2_an71_consvotes, lm_exp2_an71_consvotes.vcovCL)
lm_exp2_an71_consvotes.clse

lm_exp3_an71_consvotes.vcovCL=cluster.vcov(lm_exp3_an71_consvotes, data_analysis_1871_fin$reg_bez)
lm_exp3_an71_consvotes.clse=coeftest(lm_exp3_an71_consvotes, lm_exp3_an71_consvotes.vcovCL)
lm_exp3_an71_consvotes.clse

lm_exp4_an71_consvotes.vcovCL=cluster.vcov(lm_exp4_an71_consvotes, data_analysis_1871_fin$reg_bez)
lm_exp4_an71_consvotes.clse=coeftest(lm_exp4_an71_consvotes, lm_exp4_an71_consvotes.vcovCL)
lm_exp4_an71_consvotes.clse

lm_exp5_an71_consvotes.vcovCL=cluster.vcov(lm_exp5_an71_consvotes, data_analysis_1871_fin$reg_bez)
lm_exp5_an71_consvotes.clse=coeftest(lm_exp5_an71_consvotes, lm_exp5_an71_consvotes.vcovCL)
lm_exp5_an71_consvotes.clse

lm_exp1_an71_consvotes_ctrl.vcovCL=cluster.vcov(lm_exp1_an71_consvotes_ctrl, data_analysis_1871_fin$reg_bez)
lm_exp1_an71_consvotes_ctrl.clse=coeftest(lm_exp1_an71_consvotes_ctrl, lm_exp1_an71_consvotes_ctrl.vcovCL)
lm_exp1_an71_consvotes_ctrl.clse

lm_exp2_an71_consvotes_ctrl.vcovCL=cluster.vcov(lm_exp2_an71_consvotes_ctrl, data_analysis_1871_fin$reg_bez)
lm_exp2_an71_consvotes_ctrl.clse=coeftest(lm_exp2_an71_consvotes_ctrl, lm_exp2_an71_consvotes_ctrl.vcovCL)
lm_exp2_an71_consvotes_ctrl.clse

lm_exp3_an71_consvotes_ctrl.vcovCL=cluster.vcov(lm_exp3_an71_consvotes_ctrl, data_analysis_1871_fin$reg_bez)
lm_exp3_an71_consvotes_ctrl.clse=coeftest(lm_exp3_an71_consvotes_ctrl, lm_exp3_an71_consvotes_ctrl.vcovCL)
lm_exp3_an71_consvotes_ctrl.clse

lm_exp4_an71_consvotes_ctrl.vcovCL=cluster.vcov(lm_exp4_an71_consvotes_ctrl, data_analysis_1871_fin$reg_bez)
lm_exp4_an71_consvotes_ctrl.clse=coeftest(lm_exp4_an71_consvotes_ctrl, lm_exp4_an71_consvotes_ctrl.vcovCL)
lm_exp4_an71_consvotes_ctrl.clse

lm_exp5_an71_consvotes_ctrl.vcovCL=cluster.vcov(lm_exp5_an71_consvotes_ctrl, data_analysis_1871_fin$reg_bez)
lm_exp5_an71_consvotes_ctrl.clse=coeftest(lm_exp5_an71_consvotes_ctrl, lm_exp5_an71_consvotes_ctrl.vcovCL)
lm_exp5_an71_consvotes_ctrl.clse



###########################
### NET ELECTORAL DISPUTES
### TABLE 3 IN THE ARTICLE
###########################

library(AER)

qp_exp1_an71_disputes=glm(NetDisputes ~ BDEI_score, family=quasipoisson(link = "log"), data=data_analysis_1871_fin)
summary(qp_exp1_an71_disputes)

qp_exp2_an71_disputes=glm(NetDisputes ~ BDEI_score2, family=quasipoisson(link = "log"), data=data_analysis_1871_fin)
summary(qp_exp2_an71_disputes)

qp_exp3_an71_disputes=glm(NetDisputes ~ BDEI_score3, family=quasipoisson(link = "log"), data=data_analysis_1871_fin)
summary(qp_exp3_an71_disputes)

qp_exp4_an71_disputes=glm(NetDisputes ~ BDEI_score4, family=quasipoisson(link = "log"), data=data_analysis_1871_fin)
summary(qp_exp4_an71_disputes)

qp_exp5_an71_disputes=glm(NetDisputes ~ BDEI_score5, family=quasipoisson(link = "log"), data=data_analysis_1871_fin)
summary(qp_exp5_an71_disputes)

qp_exp1_an71_disputes_ctrl=glm(NetDisputes ~ BDEI_score + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, family=quasipoisson(link = "log"), data=data_analysis_1871_fin)
summary(qp_exp1_an71_disputes_ctrl)

qp_exp2_an71_disputes_ctrl=glm(NetDisputes ~ BDEI_score2 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, family=quasipoisson(link = "log"), data=data_analysis_1871_fin)
summary(qp_exp2_an71_disputes_ctrl)

qp_exp3_an71_disputes_ctrl=glm(NetDisputes ~ BDEI_score3 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, family=quasipoisson(link = "log"), data=data_analysis_1871_fin)
summary(qp_exp3_an71_disputes_ctrl)

qp_exp4_an71_disputes_ctrl=glm(NetDisputes ~ BDEI_score4 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, family=quasipoisson(link = "log"), data=data_analysis_1871_fin)
summary(qp_exp4_an71_disputes_ctrl)

qp_exp5_an71_disputes_ctrl=glm(NetDisputes ~ BDEI_score5 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, family=quasipoisson(link = "log"), data=data_analysis_1871_fin)
summary(qp_exp5_an71_disputes_ctrl)

### CLUSTERED STANDARD ERRORS

qp_exp1_an71_disputes.vcovCL=cluster.vcov(qp_exp1_an71_disputes, data_analysis_1871_fin$reg_bez)
qp_exp1_an71_disputes.clse=coeftest(qp_exp1_an71_disputes, qp_exp1_an71_disputes.vcovCL)
qp_exp1_an71_disputes.clse

qp_exp2_an71_disputes.vcovCL=cluster.vcov(qp_exp2_an71_disputes, data_analysis_1871_fin$reg_bez)
qp_exp2_an71_disputes.clse=coeftest(qp_exp2_an71_disputes, qp_exp2_an71_disputes.vcovCL)
qp_exp2_an71_disputes.clse

qp_exp3_an71_disputes.vcovCL=cluster.vcov(qp_exp3_an71_disputes, data_analysis_1871_fin$reg_bez)
qp_exp3_an71_disputes.clse=coeftest(qp_exp3_an71_disputes, qp_exp3_an71_disputes.vcovCL)
qp_exp3_an71_disputes.clse

qp_exp4_an71_disputes.vcovCL=cluster.vcov(qp_exp4_an71_disputes, data_analysis_1871_fin$reg_bez)
qp_exp4_an71_disputes.clse=coeftest(qp_exp4_an71_disputes, qp_exp4_an71_disputes.vcovCL)
qp_exp4_an71_disputes.clse

qp_exp5_an71_disputes.vcovCL=cluster.vcov(qp_exp5_an71_disputes, data_analysis_1871_fin$reg_bez)
qp_exp5_an71_disputes.clse=coeftest(qp_exp5_an71_disputes, qp_exp5_an71_disputes.vcovCL)
qp_exp5_an71_disputes.clse

qp_exp1_an71_disputes_ctrl.vcovCL=cluster.vcov(qp_exp1_an71_disputes_ctrl, data_analysis_1871_fin$reg_bez)
qp_exp1_an71_disputes_ctrl.clse=coeftest(qp_exp1_an71_disputes_ctrl, qp_exp1_an71_disputes_ctrl.vcovCL)
qp_exp1_an71_disputes_ctrl.clse

qp_exp2_an71_disputes_ctrl.vcovCL=cluster.vcov(qp_exp2_an71_disputes_ctrl, data_analysis_1871_fin$reg_bez)
qp_exp2_an71_disputes_ctrl.clse=coeftest(qp_exp2_an71_disputes_ctrl, qp_exp2_an71_disputes_ctrl.vcovCL)
qp_exp2_an71_disputes_ctrl.clse

qp_exp3_an71_disputes_ctrl.vcovCL=cluster.vcov(qp_exp3_an71_disputes_ctrl, data_analysis_1871_fin$reg_bez)
qp_exp3_an71_disputes_ctrl.clse=coeftest(qp_exp3_an71_disputes_ctrl, qp_exp3_an71_disputes_ctrl.vcovCL)
qp_exp3_an71_disputes_ctrl.clse

qp_exp4_an71_disputes_ctrl.vcovCL=cluster.vcov(qp_exp4_an71_disputes_ctrl, data_analysis_1871_fin$reg_bez)
qp_exp4_an71_disputes_ctrl.clse=coeftest(qp_exp4_an71_disputes_ctrl, qp_exp4_an71_disputes_ctrl.vcovCL)
qp_exp4_an71_disputes_ctrl.clse

qp_exp5_an71_disputes_ctrl.vcovCL=cluster.vcov(qp_exp5_an71_disputes_ctrl, data_analysis_1871_fin$reg_bez)
qp_exp5_an71_disputes_ctrl.clse=coeftest(qp_exp5_an71_disputes_ctrl, qp_exp5_an71_disputes_ctrl.vcovCL)
qp_exp5_an71_disputes_ctrl.clse



###########################
### FIGURES IN THE ARTICLE
###########################

###########################
### PREDICT FUNCTION WITH ADJUSTED VARIANCE-COVARIANCE MATRIX
###########################

### BASED ON: https://stackoverflow.com/questions/3790116/using-clustered-covariance-matrix-in-predict-lm

predict.rob = function(x,clcov,newdata){
  if(missing(newdata)){ newdata = x$model }
  tt = terms(x)
  Terms = delete.response(tt)
  m.mat = model.matrix(Terms,data=newdata)
  m.coef = x$coef
  fit = as.vector(m.mat %*% x$coef)
  se.fit = sqrt(diag(m.mat%*%clcov%*%t(m.mat)))
  return(list(fit=fit,se.fit=se.fit))}



###########################
### PREDICTED VALUE PLOTS
###########################

###########################
### CREATE FIGURE: BDEI SCORE V1 AND LANDHOLDING INEQUALITY
###########################

###########################
### NEW DATA FRAME
###########################

nd = data.frame(BDEI_score=seq(min(data_analysis_1871_fin$BDEI_score, na.rm=T), max(data_analysis_1871_fin$BDEI_score, na.rm=T),length.out=10))



###########################
### PREDICT OUTCOME VALUES
###########################

pred.p1 = predict.rob(lm_exp1_an71_landineq, clcov=lm_exp1_an71_landineq.vcovCL, newdata=nd)
pred.p1.table = cbind(pred.p1$fit, pred.p1$se.fit)
fit.p1 = pred.p1
fit.p1 = pred.p1$fit
low.p1 = pred.p1$fit - 1.96*pred.p1$se.fit
high.p1 = pred.p1$fit + 1.96*pred.p1$se.fit
cis.p1 = cbind(fit.p1, low.p1, high.p1)



###########################
### CREATE TWO SEPARATE PLOTS
### PLOT 1: PREDICTED VALUES
### PLOT 2: HISTOGRAM OF INDEPENDENT VARIABLE
###########################

library(ggplot2)

pred.p1.gg=as.data.frame(pred.p1)
cis.p1.gg=as.data.frame(cis.p1)

plot1=ggplot(pred.p1.gg, aes(x=nd$BDEI_score, y=fit.p1)) +
  geom_ribbon(aes(ymin=cis.p1.gg$low.p1, ymax=cis.p1.gg$high.p1), alpha=0.1, fill="Blue", color="Blue", linetype = 2) + scale_fill_brewer(palette="Blues") + ylab("Land Inequality (Gini)") + ggtitle("Predicted Values Plot: BDEI Score v1 and Landholding Inequality") + geom_line(size=2) + theme(axis.text=element_text(size=16,face="bold",color="Black"), axis.title=element_text(size=16,face="bold"), title=element_text(size=16,face="bold"), legend.text=element_text(size=16,face="bold",color="Black")) + scale_x_continuous(limits=c(min(nd$BDEI_score), max(nd$BDEI_score))) +
  theme(plot.title = element_text(hjust = 0.5), axis.title.x = element_blank())

plot1

plot2=ggplot(data_analysis_1871_fin, aes(x=data_analysis_1871_fin$BDEI_score)) + geom_histogram(aes(BDEI_score), position="identity", linetype=1, fill="gray60", data = data_analysis_1871_fin, alpha=0.5, bins = 30) + scale_y_continuous(expand = c(0,0)) + scale_x_continuous(limits=c(min(nd$BDEI_score), max(nd$BDEI_score))) + xlab("BDEI Score v1 (Min-Max)") + ylab("Count") + theme(axis.text=element_text(size=16,face="bold",color="Black"), axis.title=element_text(size=16,face="bold"), title=element_text(size=16,face="bold"), legend.text=element_text(size=16,face="bold",color="Black"))

plot2



###########################
### COMBINE PLOT 1 AND PLOT 2 IN A SINGLE FIGURE
### FIGURE 5 IN THE ARTICLE
###########################

library(egg)
egg::ggarrange(plot1, plot2, heights = c(0.75, 0.25))



###########################
### CREATE FIGURE: BDEI SCORE V1 AND CONSERVATIVE PARTY VOTE SHARE
###########################

###########################
#### PREDICT OUTCOME VALUES
###########################

pred.p2 = predict.rob(lm_exp1_an71_consvotes, clcov=lm_exp1_an71_consvotes.vcovCL, newdata=nd)
pred.p2.table = cbind(pred.p2$fit, pred.p2$se.fit)
fit.p2 = pred.p2
fit.p2 = pred.p2$fit
low.p2 = pred.p2$fit - 1.96*pred.p2$se.fit
high.p2 = pred.p2$fit + 1.96*pred.p2$se.fit
cis.p2 = cbind(fit.p2, low.p2, high.p2)



###########################
### CREATE TWO SEPARATE PLOTS
### PLOT 1: PREDICTED VALUES
### PLOT 2: HISTOGRAM OF INDEPENDENT VARIABLE
###########################

pred.p2.gg=as.data.frame(pred.p2)
cis.p2.gg=as.data.frame(cis.p2)

plot1=ggplot(pred.p2.gg, aes(x=nd$BDEI_score, y=fit)) +
  geom_ribbon(aes(ymin=cis.p2.gg$low.p2, ymax=cis.p2.gg$high.p2), alpha=0.1, fill="Blue", color="Blue", linetype = 2) + scale_fill_brewer(palette="Blues") + xlab("BDEI Score v1 (Min-Max)") + ylab("Conservative Party Vote Share") + ggtitle("Predicted Values Plot: BDEI Score v1 and Conservative Party Vote Share (1871)") + geom_line(size=2) + theme(axis.text=element_text(size=16,face="bold",color="Black"), axis.title=element_text(size=16,face="bold"), title=element_text(size=16,face="bold"), legend.text=element_text(size=16,face="bold",color="Black")) +
  theme(plot.title = element_text(hjust = 0.5), axis.title.x = element_blank()) + scale_x_continuous(limits=c(min(nd$BDEI_score), max(nd$BDEI_score)))

plot1

data_analysis_1871_fin_ggplot=data_analysis_1871_fin[-which(is.na(data_analysis_1871_fin$votes_cons_share_1871)),]

plot2=ggplot(data_analysis_1871_fin_ggplot, aes(x=data_analysis_1871_fin_ggplot$BDEI_score)) + geom_histogram(aes(BDEI_score), position="identity", linetype=1, fill="gray60", data = data_analysis_1871_fin_ggplot, alpha=0.5, bins = 30) + scale_y_continuous(expand = c(0,0)) + scale_x_continuous(limits=c(min(nd$BDEI_score), max(nd$BDEI_score))) + xlab("BDEI Score v1 (Min-Max)") + ylab("Count") + theme(axis.text=element_text(size=16,face="bold",color="Black"), axis.title=element_text(size=16,face="bold"), title=element_text(size=16,face="bold"), legend.text=element_text(size=14,face="bold",color="Black"))

plot2



###########################
### COMBINE PLOT 1 AND PLOT 2 IN A SINGLE FIGURE
### FIGURE 6 IN THE ARTICLE
###########################

egg::ggarrange(plot1, plot2, heights = c(0.75, 0.25))



###########################
### ADDITIONAL EMPIRICAL ANALYSIS IN THE SUPPLEMENTARY MATERIAL
###########################

###########################
### DESCRIPTIVE SUMMARY STATISTICS
### TABLE A1 IN THE SUPPLEMENTARY MATERIAL
###########################

summary(data_analysis_1871_fin)



###########################
### TOBIT MODELS AS AN ALTERNATIVE SPECIFICATION
###########################

###########################
### LANDHOLDING INEQUALITY
### TABLE A2 IN THE SUPPLEMENTARY MATERIAL
###########################

tobit_exp1_an71_landineq=tobit(landgini ~ BDEI_score, left=0, right=1, data=data_analysis_1871_fin)
summary(tobit_exp1_an71_landineq)

tobit_exp2_an71_landineq=tobit(landgini ~ BDEI_score2, left=0, right=1, data=data_analysis_1871_fin)
summary(tobit_exp2_an71_landineq)

tobit_exp3_an71_landineq=tobit(landgini ~ BDEI_score3, left=0, right=1, data=data_analysis_1871_fin)
summary(tobit_exp3_an71_landineq)

tobit_exp4_an71_landineq=tobit(landgini ~ BDEI_score4, left=0, right=1, data=data_analysis_1871_fin)
summary(tobit_exp4_an71_landineq)

tobit_exp5_an71_landineq=tobit(landgini ~ BDEI_score5, left=0, right=1, data=data_analysis_1871_fin)
summary(tobit_exp5_an71_landineq)

tobit_exp1_an71_landineq_ctrl=tobit(landgini ~ BDEI_score + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, left=0, right=1, data=data_analysis_1871_fin)
summary(tobit_exp1_an71_landineq_ctrl)

tobit_exp2_an71_landineq_ctrl=tobit(landgini ~ BDEI_score2 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, left=0, right=1, data=data_analysis_1871_fin)
summary(tobit_exp2_an71_landineq_ctrl)

tobit_exp3_an71_landineq_ctrl=tobit(landgini ~ BDEI_score3 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, left=0, right=1, data=data_analysis_1871_fin)
summary(tobit_exp3_an71_landineq_ctrl)

tobit_exp4_an71_landineq_ctrl=tobit(landgini ~ BDEI_score4 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, left=0, right=1, data=data_analysis_1871_fin)
summary(tobit_exp4_an71_landineq_ctrl)

tobit_exp5_an71_landineq_ctrl=tobit(landgini ~ BDEI_score5 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, left=0, right=1, data=data_analysis_1871_fin)
summary(tobit_exp5_an71_landineq_ctrl)



###########################
### CONSERVATIVE PARTY VOTE SHARE
### TABLE A3 IN THE SUPPLEMENTARY MATERIAL
###########################

tobit_exp1_an71_consvotes=tobit(votes_cons_share_1871 ~ BDEI_score, left=0, right=1, data=data_analysis_1871_fin)
summary(tobit_exp1_an71_consvotes)

tobit_exp2_an71_consvotes=tobit(votes_cons_share_1871 ~ BDEI_score2, left=0, right=1, data=data_analysis_1871_fin)
summary(tobit_exp2_an71_consvotes)

tobit_exp3_an71_consvotes=tobit(votes_cons_share_1871 ~ BDEI_score3, left=0, right=1, data=data_analysis_1871_fin)
summary(tobit_exp3_an71_consvotes)

tobit_exp4_an71_consvotes=tobit(votes_cons_share_1871 ~ BDEI_score4, left=0, right=1, data=data_analysis_1871_fin)
summary(tobit_exp4_an71_consvotes)

tobit_exp5_an71_consvotes=tobit(votes_cons_share_1871 ~ BDEI_score5, left=0, right=1, data=data_analysis_1871_fin)
summary(tobit_exp5_an71_consvotes)

tobit_exp1_an71_consvotes_ctrl=tobit(votes_cons_share_1871 ~ BDEI_score + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, left=0, right=1, data=data_analysis_1871_fin)
summary(tobit_exp1_an71_consvotes_ctrl)

tobit_exp2_an71_consvotes_ctrl=tobit(votes_cons_share_1871 ~ BDEI_score2 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, left=0, right=1, data=data_analysis_1871_fin)
summary(tobit_exp2_an71_consvotes_ctrl)

tobit_exp3_an71_consvotes_ctrl=tobit(votes_cons_share_1871 ~ BDEI_score3 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, left=0, right=1, data=data_analysis_1871_fin)
summary(tobit_exp3_an71_consvotes_ctrl)

tobit_exp4_an71_consvotes_ctrl=tobit(votes_cons_share_1871 ~ BDEI_score4 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, left=0, right=1, data=data_analysis_1871_fin)
summary(tobit_exp4_an71_consvotes_ctrl)

tobit_exp5_an71_consvotes_ctrl=tobit(votes_cons_share_1871 ~ BDEI_score5 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, left=0, right=1, data=data_analysis_1871_fin)
summary(tobit_exp5_an71_consvotes_ctrl)



###########################
### EXTENSION 1 - INCLUDING ADDITIONAL COVARIATES
### TABLE A4 IN THE SUPPLEMENTARY MATERIAL
###########################

###########################
### LANDHOLDING INEQUALITY
###########################

lm_exp_ext1_an71_landineq_ctrl=lm(landgini ~ BDEI_score + pop + prussia + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext1_an71_landineq_ctrl)

lm_exp_ext1_an71_landineq_ctrl_bdei3=lm(landgini ~ BDEI_score3 + pop + prussia + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext1_an71_landineq_ctrl_bdei3)

lm_exp_ext1_an71_landineq_ctrl_bdei5=lm(landgini ~ BDEI_score5 + pop + prussia + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext1_an71_landineq_ctrl_bdei5)

### CLUSTERED STANDARD ERRORS

lm_exp_ext1_an71_landineq_ctrl.vcovCL=cluster.vcov(lm_exp_ext1_an71_landineq_ctrl, data_analysis_1871_fin$reg_bez)
lm_exp_ext1_an71_landineq_ctrl.clse=coeftest(lm_exp_ext1_an71_landineq_ctrl, lm_exp_ext1_an71_landineq_ctrl.vcovCL)
lm_exp_ext1_an71_landineq_ctrl.clse

lm_exp_ext1_an71_landineq_ctrl_bdei3.vcovCL=cluster.vcov(lm_exp_ext1_an71_landineq_ctrl_bdei3, data_analysis_1871_fin$reg_bez)
lm_exp_ext1_an71_landineq_ctrl_bdei3.clse=coeftest(lm_exp_ext1_an71_landineq_ctrl_bdei3, lm_exp_ext1_an71_landineq_ctrl_bdei3.vcovCL)
lm_exp_ext1_an71_landineq_ctrl_bdei3.clse

lm_exp_ext1_an71_landineq_ctrl_bdei5.vcovCL=cluster.vcov(lm_exp_ext1_an71_landineq_ctrl_bdei5, data_analysis_1871_fin$reg_bez)
lm_exp_ext1_an71_landineq_ctrl_bdei5.clse=coeftest(lm_exp_ext1_an71_landineq_ctrl_bdei5, lm_exp_ext1_an71_landineq_ctrl_bdei5.vcovCL)
lm_exp_ext1_an71_landineq_ctrl_bdei5.clse



###########################
### CONSERVATIVE PARTY VOTE SHARE
###########################

lm_exp_ext1_an71_consvotes_ctrl=lm(votes_cons_share_1871 ~ BDEI_score + pop + prussia + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext1_an71_consvotes_ctrl)

lm_exp_ext1_an71_consvotes_ctrl_bdei3=lm(votes_cons_share_1871 ~ BDEI_score3 + pop + prussia + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext1_an71_consvotes_ctrl_bdei3)

lm_exp_ext1_an71_consvotes_ctrl_bdei5=lm(votes_cons_share_1871 ~ BDEI_score5 + pop + prussia + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext1_an71_consvotes_ctrl_bdei5)

### CLUSTERED STANDARD ERRORS

lm_exp_ext1_an71_consvotes_ctrl.vcovCL=cluster.vcov(lm_exp_ext1_an71_consvotes_ctrl, data_analysis_1871_fin$reg_bez)
lm_exp_ext1_an71_consvotes_ctrl.clse=coeftest(lm_exp_ext1_an71_consvotes_ctrl, lm_exp_ext1_an71_consvotes_ctrl.vcovCL)
lm_exp_ext1_an71_consvotes_ctrl.clse

lm_exp_ext1_an71_consvotes_ctrl_bdei3.vcovCL=cluster.vcov(lm_exp_ext1_an71_consvotes_ctrl_bdei3, data_analysis_1871_fin$reg_bez)
lm_exp_ext1_an71_consvotes_ctrl_bdei3.clse=coeftest(lm_exp_ext1_an71_consvotes_ctrl_bdei3, lm_exp_ext1_an71_consvotes_ctrl_bdei3.vcovCL)
lm_exp_ext1_an71_consvotes_ctrl_bdei3.clse

lm_exp_ext1_an71_consvotes_ctrl_bdei5.vcovCL=cluster.vcov(lm_exp_ext1_an71_consvotes_ctrl_bdei5, data_analysis_1871_fin$reg_bez)
lm_exp_ext1_an71_consvotes_ctrl_bdei5.clse=coeftest(lm_exp_ext1_an71_consvotes_ctrl_bdei5, lm_exp_ext1_an71_consvotes_ctrl_bdei5.vcovCL)
lm_exp_ext1_an71_consvotes_ctrl_bdei5.clse



###########################
### NET ELECTORAL DISPUTES
###########################

qp_exp_ext1_an71_disputes_ctrl=glm(NetDisputes ~ BDEI_score + pop + prussia + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, family=quasipoisson(link = "log"), data=data_analysis_1871_fin)
summary(qp_exp_ext1_an71_disputes_ctrl)

qp_exp_ext1_an71_disputes_ctrl_bdei3=glm(NetDisputes ~ BDEI_score3 + pop + prussia + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, family=quasipoisson(link = "log"), data=data_analysis_1871_fin)
summary(qp_exp_ext1_an71_disputes_ctrl_bdei3)

qp_exp_ext1_an71_disputes_ctrl_bdei5=glm(NetDisputes ~ BDEI_score5 + pop + prussia + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, family=quasipoisson(link = "log"), data=data_analysis_1871_fin)
summary(qp_exp_ext1_an71_disputes_ctrl_bdei5)

### CLUSTERED STANDARD ERRORS

qp_exp_ext1_an71_disputes_ctrl.vcovCL=cluster.vcov(qp_exp_ext1_an71_disputes_ctrl, data_analysis_1871_fin$reg_bez)
qp_exp_ext1_an71_disputes_ctrl.clse=coeftest(qp_exp_ext1_an71_disputes_ctrl, qp_exp_ext1_an71_disputes_ctrl.vcovCL)
qp_exp_ext1_an71_disputes_ctrl.clse

qp_exp_ext1_an71_disputes_ctrl_bdei3.vcovCL=cluster.vcov(qp_exp_ext1_an71_disputes_ctrl_bdei3, data_analysis_1871_fin$reg_bez)
qp_exp_ext1_an71_disputes_ctrl_bdei3.clse=coeftest(qp_exp_ext1_an71_disputes_ctrl_bdei3, qp_exp_ext1_an71_disputes_ctrl_bdei3.vcovCL)
qp_exp_ext1_an71_disputes_ctrl_bdei3.clse

qp_exp_ext1_an71_disputes_ctrl_bdei5.vcovCL=cluster.vcov(qp_exp_ext1_an71_disputes_ctrl_bdei5, data_analysis_1871_fin$reg_bez)
qp_exp_ext1_an71_disputes_ctrl_bdei5.clse=coeftest(qp_exp_ext1_an71_disputes_ctrl_bdei5, qp_exp_ext1_an71_disputes_ctrl_bdei5.vcovCL)
qp_exp_ext1_an71_disputes_ctrl_bdei5.clse



###########################
### EXTENSION 2 - ACCOUNTING FOR A POTENTIAL EFFECT OF THE REFORMATION
### TABLE A5 IN THE SUPPLEMENTARY MATERIAL
###########################

###########################
### LANDHOLDING INEQUALITY
###########################

lm_exp_ext2_an71_landineq_ctrl=lm(landgini ~ BDEI_score + cath_pct_1871 + pop + prussia + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext2_an71_landineq_ctrl)

lm_exp_ext2_an71_landineq_ctrl_bdei3=lm(landgini ~ BDEI_score3 + cath_pct_1871 + pop + prussia + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext2_an71_landineq_ctrl_bdei3)

lm_exp_ext2_an71_landineq_ctrl_bdei5=lm(landgini ~ BDEI_score5 + cath_pct_1871 + pop + prussia + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext2_an71_landineq_ctrl_bdei5)

### CLUSTERED STANDARD ERRORS

lm_exp_ext2_an71_landineq_ctrl.vcovCL=cluster.vcov(lm_exp_ext2_an71_landineq_ctrl, data_analysis_1871_fin$reg_bez)
lm_exp_ext2_an71_landineq_ctrl.clse=coeftest(lm_exp_ext2_an71_landineq_ctrl, lm_exp_ext2_an71_landineq_ctrl.vcovCL)
lm_exp_ext2_an71_landineq_ctrl.clse

lm_exp_ext2_an71_landineq_ctrl_bdei3.vcovCL=cluster.vcov(lm_exp_ext2_an71_landineq_ctrl_bdei3, data_analysis_1871_fin$reg_bez)
lm_exp_ext2_an71_landineq_ctrl_bdei3.clse=coeftest(lm_exp_ext2_an71_landineq_ctrl_bdei3, lm_exp_ext2_an71_landineq_ctrl_bdei3.vcovCL)
lm_exp_ext2_an71_landineq_ctrl_bdei3.clse

lm_exp_ext2_an71_landineq_ctrl_bdei5.vcovCL=cluster.vcov(lm_exp_ext2_an71_landineq_ctrl_bdei5, data_analysis_1871_fin$reg_bez)
lm_exp_ext2_an71_landineq_ctrl_bdei5.clse=coeftest(lm_exp_ext2_an71_landineq_ctrl_bdei5, lm_exp_ext2_an71_landineq_ctrl_bdei5.vcovCL)
lm_exp_ext2_an71_landineq_ctrl_bdei5.clse



###########################
### CONSERVATIVE PARTY VOTE SHARE
###########################

lm_exp_ext2_an71_consvotes_ctrl=lm(votes_cons_share_1871 ~ BDEI_score + cath_pct_1871 + pop + prussia + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext2_an71_consvotes_ctrl)

lm_exp_ext2_an71_consvotes_ctrl_bdei3=lm(votes_cons_share_1871 ~ BDEI_score3 + cath_pct_1871 + pop + prussia + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext2_an71_consvotes_ctrl_bdei3)

lm_exp_ext2_an71_consvotes_ctrl_bdei5=lm(votes_cons_share_1871 ~ BDEI_score5 + cath_pct_1871 + pop + prussia + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext2_an71_consvotes_ctrl_bdei5)

### CLUSTERED STANDARD ERRORS

lm_exp_ext2_an71_consvotes_ctrl.vcovCL=cluster.vcov(lm_exp_ext2_an71_consvotes_ctrl, data_analysis_1871_fin$reg_bez)
lm_exp_ext2_an71_consvotes_ctrl.clse=coeftest(lm_exp_ext2_an71_consvotes_ctrl, lm_exp_ext2_an71_consvotes_ctrl.vcovCL)
lm_exp_ext2_an71_consvotes_ctrl.clse

lm_exp_ext2_an71_consvotes_ctrl_bdei3.vcovCL=cluster.vcov(lm_exp_ext2_an71_consvotes_ctrl_bdei3, data_analysis_1871_fin$reg_bez)
lm_exp_ext2_an71_consvotes_ctrl_bdei3.clse=coeftest(lm_exp_ext2_an71_consvotes_ctrl_bdei3, lm_exp_ext2_an71_consvotes_ctrl_bdei3.vcovCL)
lm_exp_ext2_an71_consvotes_ctrl_bdei3.clse

lm_exp_ext2_an71_consvotes_ctrl_bdei5.vcovCL=cluster.vcov(lm_exp_ext2_an71_consvotes_ctrl_bdei5, data_analysis_1871_fin$reg_bez)
lm_exp_ext2_an71_consvotes_ctrl_bdei5.clse=coeftest(lm_exp_ext2_an71_consvotes_ctrl_bdei5, lm_exp_ext2_an71_consvotes_ctrl_bdei5.vcovCL)
lm_exp_ext2_an71_consvotes_ctrl_bdei5.clse



###########################
### NET ELECTORAL DISPUTES
###########################

qp_exp_ext2_an71_disputes_ctrl=glm(NetDisputes ~ BDEI_score + cath_pct_1871 + pop + prussia + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, family=quasipoisson(link = "log"), data=data_analysis_1871_fin)
summary(qp_exp_ext2_an71_disputes_ctrl)

qp_exp_ext2_an71_disputes_ctrl_bdei3=glm(NetDisputes ~ BDEI_score3 + cath_pct_1871 + pop + prussia + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, family=quasipoisson(link = "log"), data=data_analysis_1871_fin)
summary(qp_exp_ext2_an71_disputes_ctrl_bdei3)

qp_exp_ext2_an71_disputes_ctrl_bdei5=glm(NetDisputes ~ BDEI_score5 + cath_pct_1871 + pop + prussia + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, family=quasipoisson(link = "log"), data=data_analysis_1871_fin)
summary(qp_exp_ext2_an71_disputes_ctrl_bdei5)

### CLUSTERED STANDARD ERRORS

qp_exp_ext2_an71_disputes_ctrl.vcovCL=cluster.vcov(qp_exp_ext2_an71_disputes_ctrl, data_analysis_1871_fin$reg_bez)
qp_exp_ext2_an71_disputes_ctrl.clse=coeftest(qp_exp_ext2_an71_disputes_ctrl, qp_exp_ext2_an71_disputes_ctrl.vcovCL)
qp_exp_ext2_an71_disputes_ctrl.clse

qp_exp_ext2_an71_disputes_ctrl_bdei3.vcovCL=cluster.vcov(qp_exp_ext2_an71_disputes_ctrl_bdei3, data_analysis_1871_fin$reg_bez)
qp_exp_ext2_an71_disputes_ctrl_bdei3.clse=coeftest(qp_exp_ext2_an71_disputes_ctrl_bdei3, qp_exp_ext2_an71_disputes_ctrl_bdei3.vcovCL)
qp_exp_ext2_an71_disputes_ctrl_bdei3.clse

qp_exp_ext2_an71_disputes_ctrl_bdei5.vcovCL=cluster.vcov(qp_exp_ext2_an71_disputes_ctrl_bdei5, data_analysis_1871_fin$reg_bez)
qp_exp_ext2_an71_disputes_ctrl_bdei5.clse=coeftest(qp_exp_ext2_an71_disputes_ctrl_bdei5, qp_exp_ext2_an71_disputes_ctrl_bdei5.vcovCL)
qp_exp_ext2_an71_disputes_ctrl_bdei5.clse



###########################
### EXTENSION 3 - USING AN ALTERNATIVE VERSION OF THE BDEI SCORE
### TABLE A6 IN THE SUPPLEMENTARY MATERIAL
###########################

###########################
### LANDHOLDING INEQUALITY
###########################

lm_exp_ext3_an71_landineq_ctrl=lm(landgini ~ BDEI_score_alt + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext3_an71_landineq_ctrl)

lm_exp_ext3_an71_landineq_ctrl_bdei3=lm(landgini ~ BDEI_score_alt3 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext3_an71_landineq_ctrl_bdei3)

lm_exp_ext3_an71_landineq_ctrl_bdei5=lm(landgini ~ BDEI_score_alt5 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext3_an71_landineq_ctrl_bdei5)

### CLUSTERED STANDARD ERRORS

lm_exp_ext3_an71_landineq_ctrl.vcovCL=cluster.vcov(lm_exp_ext3_an71_landineq_ctrl, data_analysis_1871_fin$reg_bez)
lm_exp_ext3_an71_landineq_ctrl.clse=coeftest(lm_exp_ext3_an71_landineq_ctrl, lm_exp_ext3_an71_landineq_ctrl.vcovCL)
lm_exp_ext3_an71_landineq_ctrl.clse

lm_exp_ext3_an71_landineq_ctrl_bdei3.vcovCL=cluster.vcov(lm_exp_ext3_an71_landineq_ctrl_bdei3, data_analysis_1871_fin$reg_bez)
lm_exp_ext3_an71_landineq_ctrl_bdei3.clse=coeftest(lm_exp_ext3_an71_landineq_ctrl_bdei3, lm_exp_ext3_an71_landineq_ctrl_bdei3.vcovCL)
lm_exp_ext3_an71_landineq_ctrl_bdei3.clse

lm_exp_ext3_an71_landineq_ctrl_bdei5.vcovCL=cluster.vcov(lm_exp_ext3_an71_landineq_ctrl_bdei5, data_analysis_1871_fin$reg_bez)
lm_exp_ext3_an71_landineq_ctrl_bdei5.clse=coeftest(lm_exp_ext3_an71_landineq_ctrl_bdei5, lm_exp_ext3_an71_landineq_ctrl_bdei5.vcovCL)
lm_exp_ext3_an71_landineq_ctrl_bdei5.clse



###########################
### CONSERVATIVE PARTY VOTE SHARE
###########################

lm_exp_ext3_an71_consvotes_ctrl=lm(votes_cons_share_1871 ~ BDEI_score_alt + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext3_an71_consvotes_ctrl)

lm_exp_ext3_an71_consvotes_ctrl_bdei3=lm(votes_cons_share_1871 ~ BDEI_score_alt3 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext3_an71_consvotes_ctrl_bdei3)

lm_exp_ext3_an71_consvotes_ctrl_bdei5=lm(votes_cons_share_1871 ~ BDEI_score_alt5 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext3_an71_consvotes_ctrl_bdei5)

### CLUSTERED STANDARD ERRORS

lm_exp_ext3_an71_consvotes_ctrl.vcovCL=cluster.vcov(lm_exp_ext3_an71_consvotes_ctrl, data_analysis_1871_fin$reg_bez)
lm_exp_ext3_an71_consvotes_ctrl.clse=coeftest(lm_exp_ext3_an71_consvotes_ctrl, lm_exp_ext3_an71_consvotes_ctrl.vcovCL)
lm_exp_ext3_an71_consvotes_ctrl.clse

lm_exp_ext3_an71_consvotes_ctrl_bdei3.vcovCL=cluster.vcov(lm_exp_ext3_an71_consvotes_ctrl_bdei3, data_analysis_1871_fin$reg_bez)
lm_exp_ext3_an71_consvotes_ctrl_bdei3.clse=coeftest(lm_exp_ext3_an71_consvotes_ctrl_bdei3, lm_exp_ext3_an71_consvotes_ctrl_bdei3.vcovCL)
lm_exp_ext3_an71_consvotes_ctrl_bdei3.clse

lm_exp_ext3_an71_consvotes_ctrl_bdei5.vcovCL=cluster.vcov(lm_exp_ext3_an71_consvotes_ctrl_bdei5, data_analysis_1871_fin$reg_bez)
lm_exp_ext3_an71_consvotes_ctrl_bdei5.clse=coeftest(lm_exp_ext3_an71_consvotes_ctrl_bdei5, lm_exp_ext3_an71_consvotes_ctrl_bdei5.vcovCL)
lm_exp_ext3_an71_consvotes_ctrl_bdei5.clse



###########################
### NET ELECTORAL DISPUTES
###########################

qp_exp_ext3_an71_disputes_ctrl=glm(NetDisputes ~ BDEI_score_alt + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, family=quasipoisson(link = "log"), data=data_analysis_1871_fin)
summary(qp_exp_ext3_an71_disputes_ctrl)

qp_exp_ext3_an71_disputes_ctrl_bdei3=glm(NetDisputes ~ BDEI_score_alt3 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, family=quasipoisson(link = "log"), data=data_analysis_1871_fin)
summary(qp_exp_ext3_an71_disputes_ctrl_bdei3)

qp_exp_ext3_an71_disputes_ctrl_bdei5=glm(NetDisputes ~ BDEI_score_alt5 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, family=quasipoisson(link = "log"), data=data_analysis_1871_fin)
summary(qp_exp_ext3_an71_disputes_ctrl_bdei5)

### CLUSTERED STANDARD ERRORS

qp_exp_ext3_an71_disputes_ctrl.vcovCL=cluster.vcov(qp_exp_ext3_an71_disputes_ctrl, data_analysis_1871_fin$reg_bez)
qp_exp_ext3_an71_disputes_ctrl.clse=coeftest(qp_exp_ext3_an71_disputes_ctrl, qp_exp_ext3_an71_disputes_ctrl.vcovCL)
qp_exp_ext3_an71_disputes_ctrl.clse

qp_exp_ext3_an71_disputes_ctrl_bdei3.vcovCL=cluster.vcov(qp_exp_ext3_an71_disputes_ctrl_bdei3, data_analysis_1871_fin$reg_bez)
qp_exp_ext3_an71_disputes_ctrl_bdei3.clse=coeftest(qp_exp_ext3_an71_disputes_ctrl_bdei3, qp_exp_ext3_an71_disputes_ctrl_bdei3.vcovCL)
qp_exp_ext3_an71_disputes_ctrl_bdei3.clse

qp_exp_ext3_an71_disputes_ctrl_bdei5.vcovCL=cluster.vcov(qp_exp_ext3_an71_disputes_ctrl_bdei5, data_analysis_1871_fin$reg_bez)
qp_exp_ext3_an71_disputes_ctrl_bdei5.clse=coeftest(qp_exp_ext3_an71_disputes_ctrl_bdei5, qp_exp_ext3_an71_disputes_ctrl_bdei5.vcovCL)
qp_exp_ext3_an71_disputes_ctrl_bdei5.clse



###########################
### EXTENSION 4 - CONDITIONING LANDHOLDING INEQUALITY ON THE SIZE OF THE AGRICULTURAL WORKFORCE
###########################

###########################
### OLS REGRESSION
### TABLE A7 IN THE SUPPLEMENTARY MATERIAL
###########################

lm_exp1_an71_01=lm(landgini ~ BDEI_score, data=data_analysis_1871_fin_agric)
summary(lm_exp1_an71_01)

lm_exp2_an71_01=lm(landgini ~ BDEI_score2, data=data_analysis_1871_fin_agric)
summary(lm_exp2_an71_01)

lm_exp3_an71_01=lm(landgini ~ BDEI_score3, data=data_analysis_1871_fin_agric)
summary(lm_exp3_an71_01)

lm_exp4_an71_01=lm(landgini ~ BDEI_score4, data=data_analysis_1871_fin_agric)
summary(lm_exp4_an71_01)

lm_exp5_an71_01=lm(landgini ~ BDEI_score5, data=data_analysis_1871_fin_agric)
summary(lm_exp5_an71_01)

lm_exp1_an71_01_ctrl=lm(landgini ~ BDEI_score + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin_agric)
summary(lm_exp1_an71_01_ctrl)

lm_exp2_an71_01_ctrl=lm(landgini ~ BDEI_score2 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin_agric)
summary(lm_exp2_an71_01_ctrl)

lm_exp3_an71_01_ctrl=lm(landgini ~ BDEI_score3 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin_agric)
summary(lm_exp3_an71_01_ctrl)

lm_exp4_an71_01_ctrl=lm(landgini ~ BDEI_score4 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin_agric)
summary(lm_exp4_an71_01_ctrl)

lm_exp5_an71_01_ctrl=lm(landgini ~ BDEI_score5 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin_agric)
summary(lm_exp5_an71_01_ctrl)

### CLUSTERED STANDARD ERRORS

lm_exp1_an71_01.vcovCL=cluster.vcov(lm_exp1_an71_01, data_analysis_1871_fin_agric$reg_bez)
lm_exp1_an71_01.clse=coeftest(lm_exp1_an71_01, lm_exp1_an71_01.vcovCL)
lm_exp1_an71_01.clse

lm_exp2_an71_01.vcovCL=cluster.vcov(lm_exp2_an71_01, data_analysis_1871_fin_agric$reg_bez)
lm_exp2_an71_01.clse=coeftest(lm_exp2_an71_01, lm_exp2_an71_01.vcovCL)
lm_exp2_an71_01.clse

lm_exp3_an71_01.vcovCL=cluster.vcov(lm_exp3_an71_01, data_analysis_1871_fin_agric$reg_bez)
lm_exp3_an71_01.clse=coeftest(lm_exp3_an71_01, lm_exp3_an71_01.vcovCL)
lm_exp3_an71_01.clse

lm_exp4_an71_01.vcovCL=cluster.vcov(lm_exp4_an71_01, data_analysis_1871_fin_agric$reg_bez)
lm_exp4_an71_01.clse=coeftest(lm_exp4_an71_01, lm_exp4_an71_01.vcovCL)
lm_exp4_an71_01.clse

lm_exp5_an71_01.vcovCL=cluster.vcov(lm_exp5_an71_01, data_analysis_1871_fin_agric$reg_bez)
lm_exp5_an71_01.clse=coeftest(lm_exp5_an71_01, lm_exp5_an71_01.vcovCL)
lm_exp5_an71_01.clse

lm_exp1_an71_01_ctrl.vcovCL=cluster.vcov(lm_exp1_an71_01_ctrl, data_analysis_1871_fin_agric$reg_bez)
lm_exp1_an71_01_ctrl.clse=coeftest(lm_exp1_an71_01_ctrl, lm_exp1_an71_01_ctrl.vcovCL)
lm_exp1_an71_01_ctrl.clse

lm_exp2_an71_01_ctrl.vcovCL=cluster.vcov(lm_exp2_an71_01_ctrl, data_analysis_1871_fin_agric$reg_bez)
lm_exp2_an71_01_ctrl.clse=coeftest(lm_exp2_an71_01_ctrl, lm_exp2_an71_01_ctrl.vcovCL)
lm_exp2_an71_01_ctrl.clse

lm_exp3_an71_01_ctrl.vcovCL=cluster.vcov(lm_exp3_an71_01_ctrl, data_analysis_1871_fin_agric$reg_bez)
lm_exp3_an71_01_ctrl.clse=coeftest(lm_exp3_an71_01_ctrl, lm_exp3_an71_01_ctrl.vcovCL)
lm_exp3_an71_01_ctrl.clse

lm_exp4_an71_01_ctrl.vcovCL=cluster.vcov(lm_exp4_an71_01_ctrl, data_analysis_1871_fin_agric$reg_bez)
lm_exp4_an71_01_ctrl.clse=coeftest(lm_exp4_an71_01_ctrl, lm_exp4_an71_01_ctrl.vcovCL)
lm_exp4_an71_01_ctrl.clse

lm_exp5_an71_01_ctrl.vcovCL=cluster.vcov(lm_exp5_an71_01_ctrl, data_analysis_1871_fin_agric$reg_bez)
lm_exp5_an71_01_ctrl.clse=coeftest(lm_exp5_an71_01_ctrl, lm_exp5_an71_01_ctrl.vcovCL)
lm_exp5_an71_01_ctrl.clse



###########################
### TOBIT MODELS
### TABLE A8 IN THE SUPPLEMENTARY MATERIAL
###########################

tobit_exp1_an71_01=tobit(landgini ~ BDEI_score, left=0, right=1, data=data_analysis_1871_fin_agric)
summary(tobit_exp1_an71_01)

tobit_exp2_an71_01=tobit(landgini ~ BDEI_score2, left=0, right=1, data=data_analysis_1871_fin_agric)
summary(tobit_exp2_an71_01)

tobit_exp3_an71_01=tobit(landgini ~ BDEI_score3, left=0, right=1, data=data_analysis_1871_fin_agric)
summary(tobit_exp3_an71_01)

tobit_exp4_an71_01=tobit(landgini ~ BDEI_score4, left=0, right=1, data=data_analysis_1871_fin_agric)
summary(tobit_exp4_an71_01)

tobit_exp5_an71_01=tobit(landgini ~ BDEI_score5, left=0, right=1, data=data_analysis_1871_fin_agric)
summary(tobit_exp5_an71_01)

tobit_exp1_an71_01_ctrl=tobit(landgini ~ BDEI_score + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, left=0, right=1, data=data_analysis_1871_fin_agric)
summary(tobit_exp1_an71_01_ctrl)

tobit_exp2_an71_01_ctrl=tobit(landgini ~ BDEI_score2 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, left=0, right=1, data=data_analysis_1871_fin_agric)
summary(tobit_exp2_an71_01_ctrl)

tobit_exp3_an71_01_ctrl=tobit(landgini ~ BDEI_score3 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, left=0, right=1, data=data_analysis_1871_fin_agric)
summary(tobit_exp3_an71_01_ctrl)

tobit_exp4_an71_01_ctrl=tobit(landgini ~ BDEI_score4 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, left=0, right=1, data=data_analysis_1871_fin_agric)
summary(tobit_exp4_an71_01_ctrl)

tobit_exp5_an71_01_ctrl=tobit(landgini ~ BDEI_score5 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, left=0, right=1, data=data_analysis_1871_fin_agric)
summary(tobit_exp5_an71_01_ctrl)



###########################
### EXTENSION 5 - TWO-STAGE LEAST SQUARES MODELS
###########################

###########################
### FIRST-STAGE RESULTS (SEE ABOVE)
### PREDICTING OUTBREAK INTENSITY BASED ON TIMING
### TABLE A9 IN THE SUPPLEMENTARY MATERIAL
###########################

summary(lm_predict)



###########################
### SECOND-STAGE RESULTS
### TWO-STAGE LEAST SQUARES MODELS
### TABLE A10 IN THE SUPPLEMENTARY MATERIAL
###########################

###########################
### LANDHOLDING INEQUALITY
###########################

lm_exp_ext5_an71_landineq_ctrl=lm(landgini ~ BDEI_score_pred + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext5_an71_landineq_ctrl)

lm_exp_ext5_an71_landineq_ctrl_bdei3=lm(landgini ~ BDEI_score_pred3 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext5_an71_landineq_ctrl_bdei3)

lm_exp_ext5_an71_landineq_ctrl_bdei5=lm(landgini ~ BDEI_score_pred5 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext5_an71_landineq_ctrl_bdei5)

### CLUSTERED STANDARD ERRORS

lm_exp_ext5_an71_landineq_ctrl.vcovCL=cluster.vcov(lm_exp_ext5_an71_landineq_ctrl, data_analysis_1871_fin$reg_bez)
lm_exp_ext5_an71_landineq_ctrl.clse=coeftest(lm_exp_ext5_an71_landineq_ctrl, lm_exp_ext5_an71_landineq_ctrl.vcovCL)
lm_exp_ext5_an71_landineq_ctrl.clse

lm_exp_ext5_an71_landineq_ctrl_bdei3.vcovCL=cluster.vcov(lm_exp_ext5_an71_landineq_ctrl_bdei3, data_analysis_1871_fin$reg_bez)
lm_exp_ext5_an71_landineq_ctrl_bdei3.clse=coeftest(lm_exp_ext5_an71_landineq_ctrl_bdei3, lm_exp_ext5_an71_landineq_ctrl_bdei3.vcovCL)
lm_exp_ext5_an71_landineq_ctrl_bdei3.clse

lm_exp_ext5_an71_landineq_ctrl_bdei5.vcovCL=cluster.vcov(lm_exp_ext5_an71_landineq_ctrl_bdei5, data_analysis_1871_fin$reg_bez)
lm_exp_ext5_an71_landineq_ctrl_bdei5.clse=coeftest(lm_exp_ext5_an71_landineq_ctrl_bdei5, lm_exp_ext5_an71_landineq_ctrl_bdei5.vcovCL)
lm_exp_ext5_an71_landineq_ctrl_bdei5.clse



###########################
### CONSERVATIVE PARTY VOTE SHARE
###########################

lm_exp_ext5_an71_consvotes_ctrl=lm(votes_cons_share_1871 ~ BDEI_score_pred + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext5_an71_consvotes_ctrl)

lm_exp_ext5_an71_consvotes_ctrl_bdei3=lm(votes_cons_share_1871 ~ BDEI_score_pred3 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext5_an71_consvotes_ctrl_bdei3)

lm_exp_ext5_an71_consvotes_ctrl_bdei5=lm(votes_cons_share_1871 ~ BDEI_score_pred5 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext5_an71_consvotes_ctrl_bdei5)

### CLUSTERED STANDARD ERRORS

lm_exp_ext5_an71_consvotes_ctrl.vcovCL=cluster.vcov(lm_exp_ext5_an71_consvotes_ctrl, data_analysis_1871_fin$reg_bez)
lm_exp_ext5_an71_consvotes_ctrl.clse=coeftest(lm_exp_ext5_an71_consvotes_ctrl, lm_exp_ext5_an71_consvotes_ctrl.vcovCL)
lm_exp_ext5_an71_consvotes_ctrl.clse

lm_exp_ext5_an71_consvotes_ctrl_bdei3.vcovCL=cluster.vcov(lm_exp_ext5_an71_consvotes_ctrl_bdei3, data_analysis_1871_fin$reg_bez)
lm_exp_ext5_an71_consvotes_ctrl_bdei3.clse=coeftest(lm_exp_ext5_an71_consvotes_ctrl_bdei3, lm_exp_ext5_an71_consvotes_ctrl_bdei3.vcovCL)
lm_exp_ext5_an71_consvotes_ctrl_bdei3.clse

lm_exp_ext5_an71_consvotes_ctrl_bdei5.vcovCL=cluster.vcov(lm_exp_ext5_an71_consvotes_ctrl_bdei5, data_analysis_1871_fin$reg_bez)
lm_exp_ext5_an71_consvotes_ctrl_bdei5.clse=coeftest(lm_exp_ext5_an71_consvotes_ctrl_bdei5, lm_exp_ext5_an71_consvotes_ctrl_bdei5.vcovCL)
lm_exp_ext5_an71_consvotes_ctrl_bdei5.clse



###########################
### NET ELECTORAL DISPUTES
###########################

qp_exp_ext5_an71_disputes_ctrl=glm(NetDisputes ~ BDEI_score_pred + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, family=quasipoisson(link = "log"), data=data_analysis_1871_fin)
summary(qp_exp_ext5_an71_disputes_ctrl)

qp_exp_ext5_an71_disputes_ctrl_bdei3=glm(NetDisputes ~ BDEI_score_pred3 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, family=quasipoisson(link = "log"), data=data_analysis_1871_fin)
summary(qp_exp_ext5_an71_disputes_ctrl_bdei3)

qp_exp_ext5_an71_disputes_ctrl_bdei5=glm(NetDisputes ~ BDEI_score_pred5 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, family=quasipoisson(link = "log"), data=data_analysis_1871_fin)
summary(qp_exp_ext5_an71_disputes_ctrl_bdei5)

### CLUSTERED STANDARD ERRORS

qp_exp_ext5_an71_disputes_ctrl.vcovCL=cluster.vcov(qp_exp_ext5_an71_disputes_ctrl, data_analysis_1871_fin$reg_bez)
qp_exp_ext5_an71_disputes_ctrl.clse=coeftest(qp_exp_ext5_an71_disputes_ctrl, qp_exp_ext5_an71_disputes_ctrl.vcovCL)
qp_exp_ext5_an71_disputes_ctrl.clse

qp_exp_ext5_an71_disputes_ctrl_bdei3.vcovCL=cluster.vcov(qp_exp_ext5_an71_disputes_ctrl_bdei3, data_analysis_1871_fin$reg_bez)
qp_exp_ext5_an71_disputes_ctrl_bdei3.clse=coeftest(qp_exp_ext5_an71_disputes_ctrl_bdei3, qp_exp_ext5_an71_disputes_ctrl_bdei3.vcovCL)
qp_exp_ext5_an71_disputes_ctrl_bdei3.clse

qp_exp_ext5_an71_disputes_ctrl_bdei5.vcovCL=cluster.vcov(qp_exp_ext5_an71_disputes_ctrl_bdei5, data_analysis_1871_fin$reg_bez)
qp_exp_ext5_an71_disputes_ctrl_bdei5.clse=coeftest(qp_exp_ext5_an71_disputes_ctrl_bdei5, qp_exp_ext5_an71_disputes_ctrl_bdei5.vcovCL)
qp_exp_ext5_an71_disputes_ctrl_bdei5.clse



###########################
### EXTENSION 6 - USING DUMMY VARIABLES INSTEAD OF ABSOLUTE DISTANCES TO GEOGRAPHIC FEATURES
### TABLE A11 IN THE SUPPLEMENTARY MATERIAL
###########################

###########################
### LANDHOLDING INEQUALITY
###########################

lm_exp_ext6_an71_landineq_ctrl=lm(landgini ~ BDEI_score + urban_density_norm + dummy_majport + dummy_tradecity + dummy_ocean + dummy_river + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext6_an71_landineq_ctrl)

lm_exp_ext6_an71_landineq_ctrl_bdei3=lm(landgini ~ BDEI_score3 + urban_density_norm + dummy_majport + dummy_tradecity + dummy_ocean + dummy_river + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext6_an71_landineq_ctrl_bdei3)

lm_exp_ext6_an71_landineq_ctrl_bdei5=lm(landgini ~ BDEI_score5 + urban_density_norm + dummy_majport + dummy_tradecity + dummy_ocean + dummy_river + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext6_an71_landineq_ctrl_bdei5)

### CLUSTERED STANDARD ERRORS

lm_exp_ext6_an71_landineq_ctrl.vcovCL=cluster.vcov(lm_exp_ext6_an71_landineq_ctrl, data_analysis_1871_fin$reg_bez)
lm_exp_ext6_an71_landineq_ctrl.clse=coeftest(lm_exp_ext6_an71_landineq_ctrl, lm_exp_ext6_an71_landineq_ctrl.vcovCL)
lm_exp_ext6_an71_landineq_ctrl.clse

lm_exp_ext6_an71_landineq_ctrl_bdei3.vcovCL=cluster.vcov(lm_exp_ext6_an71_landineq_ctrl_bdei3, data_analysis_1871_fin$reg_bez)
lm_exp_ext6_an71_landineq_ctrl_bdei3.clse=coeftest(lm_exp_ext6_an71_landineq_ctrl_bdei3, lm_exp_ext6_an71_landineq_ctrl_bdei3.vcovCL)
lm_exp_ext6_an71_landineq_ctrl_bdei3.clse

lm_exp_ext6_an71_landineq_ctrl_bdei5.vcovCL=cluster.vcov(lm_exp_ext6_an71_landineq_ctrl_bdei5, data_analysis_1871_fin$reg_bez)
lm_exp_ext6_an71_landineq_ctrl_bdei5.clse=coeftest(lm_exp_ext6_an71_landineq_ctrl_bdei5, lm_exp_ext6_an71_landineq_ctrl_bdei5.vcovCL)
lm_exp_ext6_an71_landineq_ctrl_bdei5.clse



###########################
### CONSERVATIVE PARTY VOTE SHARE
###########################

lm_exp_ext6_an71_consvotes_ctrl=lm(votes_cons_share_1871 ~ BDEI_score + urban_density_norm + dummy_majport + dummy_tradecity + dummy_ocean + dummy_river + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext6_an71_consvotes_ctrl)

lm_exp_ext6_an71_consvotes_ctrl_bdei3=lm(votes_cons_share_1871 ~ BDEI_score3 + urban_density_norm + dummy_majport + dummy_tradecity + dummy_ocean + dummy_river + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext6_an71_consvotes_ctrl_bdei3)

lm_exp_ext6_an71_consvotes_ctrl_bdei5=lm(votes_cons_share_1871 ~ BDEI_score5 + urban_density_norm + dummy_majport + dummy_tradecity + dummy_ocean + dummy_river + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext6_an71_consvotes_ctrl_bdei5)

### CLUSTERED STANDARD ERRORS

lm_exp_ext6_an71_consvotes_ctrl.vcovCL=cluster.vcov(lm_exp_ext6_an71_consvotes_ctrl, data_analysis_1871_fin$reg_bez)
lm_exp_ext6_an71_consvotes_ctrl.clse=coeftest(lm_exp_ext6_an71_consvotes_ctrl, lm_exp_ext6_an71_consvotes_ctrl.vcovCL)
lm_exp_ext6_an71_consvotes_ctrl.clse

lm_exp_ext6_an71_consvotes_ctrl_bdei3.vcovCL=cluster.vcov(lm_exp_ext6_an71_consvotes_ctrl_bdei3, data_analysis_1871_fin$reg_bez)
lm_exp_ext6_an71_consvotes_ctrl_bdei3.clse=coeftest(lm_exp_ext6_an71_consvotes_ctrl_bdei3, lm_exp_ext6_an71_consvotes_ctrl_bdei3.vcovCL)
lm_exp_ext6_an71_consvotes_ctrl_bdei3.clse

lm_exp_ext6_an71_consvotes_ctrl_bdei5.vcovCL=cluster.vcov(lm_exp_ext6_an71_consvotes_ctrl_bdei5, data_analysis_1871_fin$reg_bez)
lm_exp_ext6_an71_consvotes_ctrl_bdei5.clse=coeftest(lm_exp_ext6_an71_consvotes_ctrl_bdei5, lm_exp_ext6_an71_consvotes_ctrl_bdei5.vcovCL)
lm_exp_ext6_an71_consvotes_ctrl_bdei5.clse



###########################
### NET ELECTORAL DISPUTES
###########################

qp_exp_ext6_an71_disputes_ctrl=glm(NetDisputes ~ BDEI_score + urban_density_norm + dummy_majport + dummy_tradecity + dummy_ocean + dummy_river + elevation, family=quasipoisson(link = "log"), data=data_analysis_1871_fin)
summary(qp_exp_ext6_an71_disputes_ctrl)

qp_exp_ext6_an71_disputes_ctrl_bdei3=glm(NetDisputes ~ BDEI_score3 + urban_density_norm + dummy_majport + dummy_tradecity + dummy_ocean + dummy_river + elevation, family=quasipoisson(link = "log"), data=data_analysis_1871_fin)
summary(qp_exp_ext6_an71_disputes_ctrl_bdei3)

qp_exp_ext6_an71_disputes_ctrl_bdei5=glm(NetDisputes ~ BDEI_score5 + urban_density_norm + dummy_majport + dummy_tradecity + dummy_ocean + dummy_river + elevation, family=quasipoisson(link = "log"), data=data_analysis_1871_fin)
summary(qp_exp_ext6_an71_disputes_ctrl_bdei5)

### CLUSTERED STANDARD ERRORS

qp_exp_ext6_an71_disputes_ctrl.vcovCL=cluster.vcov(qp_exp_ext6_an71_disputes_ctrl, data_analysis_1871_fin$reg_bez)
qp_exp_ext6_an71_disputes_ctrl.clse=coeftest(qp_exp_ext6_an71_disputes_ctrl, qp_exp_ext6_an71_disputes_ctrl.vcovCL)
qp_exp_ext6_an71_disputes_ctrl.clse

qp_exp_ext6_an71_disputes_ctrl_bdei3.vcovCL=cluster.vcov(qp_exp_ext6_an71_disputes_ctrl_bdei3, data_analysis_1871_fin$reg_bez)
qp_exp_ext6_an71_disputes_ctrl_bdei3.clse=coeftest(qp_exp_ext6_an71_disputes_ctrl_bdei3, qp_exp_ext6_an71_disputes_ctrl_bdei3.vcovCL)
qp_exp_ext6_an71_disputes_ctrl_bdei3.clse

qp_exp_ext6_an71_disputes_ctrl_bdei5.vcovCL=cluster.vcov(qp_exp_ext6_an71_disputes_ctrl_bdei5, data_analysis_1871_fin$reg_bez)
qp_exp_ext6_an71_disputes_ctrl_bdei5.clse=coeftest(qp_exp_ext6_an71_disputes_ctrl_bdei5, qp_exp_ext6_an71_disputes_ctrl_bdei5.vcovCL)
qp_exp_ext6_an71_disputes_ctrl_bdei5.clse



###########################
### EXTENSION 7 - ACCOUNTING FOR HISTORICAL INFORMATION ASYMMETRIES
### TABLE A12 IN THE SUPPLEMENTARY MATERIAL
###########################

###########################
### LANDHOLDING INEQUALITY
###########################

lm_exp_ext7_an71_landineq_ctrl=lm(landgini ~ BDEI_score + cal_variab + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext7_an71_landineq_ctrl)

lm_exp_ext7_an71_landineq_ctrl_bdei3=lm(landgini ~ BDEI_score3 + cal_variab + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext7_an71_landineq_ctrl_bdei3)

lm_exp_ext7_an71_landineq_ctrl_bdei5=lm(landgini ~ BDEI_score5 + cal_variab + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext7_an71_landineq_ctrl_bdei5)

### CLUSTERED STANDARD ERRORS

lm_exp_ext7_an71_landineq_ctrl.vcovCL=cluster.vcov(lm_exp_ext7_an71_landineq_ctrl, data_analysis_1871_fin$reg_bez)
lm_exp_ext7_an71_landineq_ctrl.clse=coeftest(lm_exp_ext7_an71_landineq_ctrl, lm_exp_ext7_an71_landineq_ctrl.vcovCL)
lm_exp_ext7_an71_landineq_ctrl.clse

lm_exp_ext7_an71_landineq_ctrl_bdei3.vcovCL=cluster.vcov(lm_exp_ext7_an71_landineq_ctrl_bdei3, data_analysis_1871_fin$reg_bez)
lm_exp_ext7_an71_landineq_ctrl_bdei3.clse=coeftest(lm_exp_ext7_an71_landineq_ctrl_bdei3, lm_exp_ext7_an71_landineq_ctrl_bdei3.vcovCL)
lm_exp_ext7_an71_landineq_ctrl_bdei3.clse

lm_exp_ext7_an71_landineq_ctrl_bdei5.vcovCL=cluster.vcov(lm_exp_ext7_an71_landineq_ctrl_bdei5, data_analysis_1871_fin$reg_bez)
lm_exp_ext7_an71_landineq_ctrl_bdei5.clse=coeftest(lm_exp_ext7_an71_landineq_ctrl_bdei5, lm_exp_ext7_an71_landineq_ctrl_bdei5.vcovCL)
lm_exp_ext7_an71_landineq_ctrl_bdei5.clse



###########################
### CONSERVATIVE PARTY VOTE SHARE
###########################

lm_exp_ext7_an71_consvotes_ctrl=lm(votes_cons_share_1871 ~ BDEI_score + cal_variab + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext7_an71_consvotes_ctrl)

lm_exp_ext7_an71_consvotes_ctrl_bdei3=lm(votes_cons_share_1871 ~ BDEI_score3 + cal_variab + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext7_an71_consvotes_ctrl_bdei3)

lm_exp_ext7_an71_consvotes_ctrl_bdei5=lm(votes_cons_share_1871 ~ BDEI_score5 + cal_variab + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext7_an71_consvotes_ctrl_bdei5)

### CLUSTERED STANDARD ERRORS

lm_exp_ext7_an71_consvotes_ctrl.vcovCL=cluster.vcov(lm_exp_ext7_an71_consvotes_ctrl, data_analysis_1871_fin$reg_bez)
lm_exp_ext7_an71_consvotes_ctrl.clse=coeftest(lm_exp_ext7_an71_consvotes_ctrl, lm_exp_ext7_an71_consvotes_ctrl.vcovCL)
lm_exp_ext7_an71_consvotes_ctrl.clse

lm_exp_ext7_an71_consvotes_ctrl_bdei3.vcovCL=cluster.vcov(lm_exp_ext7_an71_consvotes_ctrl_bdei3, data_analysis_1871_fin$reg_bez)
lm_exp_ext7_an71_consvotes_ctrl_bdei3.clse=coeftest(lm_exp_ext7_an71_consvotes_ctrl_bdei3, lm_exp_ext7_an71_consvotes_ctrl_bdei3.vcovCL)
lm_exp_ext7_an71_consvotes_ctrl_bdei3.clse

lm_exp_ext7_an71_consvotes_ctrl_bdei5.vcovCL=cluster.vcov(lm_exp_ext7_an71_consvotes_ctrl_bdei5, data_analysis_1871_fin$reg_bez)
lm_exp_ext7_an71_consvotes_ctrl_bdei5.clse=coeftest(lm_exp_ext7_an71_consvotes_ctrl_bdei5, lm_exp_ext7_an71_consvotes_ctrl_bdei5.vcovCL)
lm_exp_ext7_an71_consvotes_ctrl_bdei5.clse



###########################
### NET ELECTORAL DISPUTES
###########################

qp_exp_ext7_an71_disputes_ctrl=glm(NetDisputes ~ BDEI_score + cal_variab + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, family=quasipoisson(link = "log"), data=data_analysis_1871_fin)
summary(qp_exp_ext7_an71_disputes_ctrl)

qp_exp_ext7_an71_disputes_ctrl_bdei3=glm(NetDisputes ~ BDEI_score3 + cal_variab + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, family=quasipoisson(link = "log"), data=data_analysis_1871_fin)
summary(qp_exp_ext7_an71_disputes_ctrl_bdei3)

qp_exp_ext7_an71_disputes_ctrl_bdei5=glm(NetDisputes ~ BDEI_score5 + cal_variab + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, family=quasipoisson(link = "log"), data=data_analysis_1871_fin)
summary(qp_exp_ext7_an71_disputes_ctrl_bdei5)

### CLUSTERED STANDARD ERRORS

qp_exp_ext7_an71_disputes_ctrl.vcovCL=cluster.vcov(qp_exp_ext7_an71_disputes_ctrl, data_analysis_1871_fin$reg_bez)
qp_exp_ext7_an71_disputes_ctrl.clse=coeftest(qp_exp_ext7_an71_disputes_ctrl, qp_exp_ext7_an71_disputes_ctrl.vcovCL)
qp_exp_ext7_an71_disputes_ctrl.clse

qp_exp_ext7_an71_disputes_ctrl_bdei3.vcovCL=cluster.vcov(qp_exp_ext7_an71_disputes_ctrl_bdei3, data_analysis_1871_fin$reg_bez)
qp_exp_ext7_an71_disputes_ctrl_bdei3.clse=coeftest(qp_exp_ext7_an71_disputes_ctrl_bdei3, qp_exp_ext7_an71_disputes_ctrl_bdei3.vcovCL)
qp_exp_ext7_an71_disputes_ctrl_bdei3.clse

qp_exp_ext7_an71_disputes_ctrl_bdei5.vcovCL=cluster.vcov(qp_exp_ext7_an71_disputes_ctrl_bdei5, data_analysis_1871_fin$reg_bez)
qp_exp_ext7_an71_disputes_ctrl_bdei5.clse=coeftest(qp_exp_ext7_an71_disputes_ctrl_bdei5, qp_exp_ext7_an71_disputes_ctrl_bdei5.vcovCL)
qp_exp_ext7_an71_disputes_ctrl_bdei5.clse



###########################
### EXTENSION 8 - INTRODUCING QUASI-RANDOM SPATIAL FIXED EFFECTS
### TABLE A13 IN THE SUPPLEMENTARY MATERIAL
###########################

###########################
### LANDHOLDING INEQUALITY
###########################

lm_exp_ext8_an71_landineq_ctrl=lm(landgini ~ BDEI_score + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation + as.factor(grid_loc)-1, data=data_analysis_1871_fin_qrSPFE)
summary(lm_exp_ext8_an71_landineq_ctrl)

lm_exp_ext8_an71_landineq_ctrl_bdei3=lm(landgini ~ BDEI_score3 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation + as.factor(grid_loc)-1, data=data_analysis_1871_fin_qrSPFE)
summary(lm_exp_ext8_an71_landineq_ctrl_bdei3)

lm_exp_ext8_an71_landineq_ctrl_bdei5=lm(landgini ~ BDEI_score5 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation + as.factor(grid_loc)-1, data=data_analysis_1871_fin_qrSPFE)
summary(lm_exp_ext8_an71_landineq_ctrl_bdei5)

### CLUSTERED STANDARD ERRORS

lm_exp_ext8_an71_landineq_ctrl.vcovCL=cluster.vcov(lm_exp_ext8_an71_landineq_ctrl, data_analysis_1871_fin_qrSPFE$reg_bez)
lm_exp_ext8_an71_landineq_ctrl.clse=coeftest(lm_exp_ext8_an71_landineq_ctrl, lm_exp_ext8_an71_landineq_ctrl.vcovCL)
lm_exp_ext8_an71_landineq_ctrl.clse

lm_exp_ext8_an71_landineq_ctrl_bdei3.vcovCL=cluster.vcov(lm_exp_ext8_an71_landineq_ctrl_bdei3, data_analysis_1871_fin_qrSPFE$reg_bez)
lm_exp_ext8_an71_landineq_ctrl_bdei3.clse=coeftest(lm_exp_ext8_an71_landineq_ctrl_bdei3, lm_exp_ext8_an71_landineq_ctrl_bdei3.vcovCL)
lm_exp_ext8_an71_landineq_ctrl_bdei3.clse

lm_exp_ext8_an71_landineq_ctrl_bdei5.vcovCL=cluster.vcov(lm_exp_ext8_an71_landineq_ctrl_bdei5, data_analysis_1871_fin_qrSPFE$reg_bez)
lm_exp_ext8_an71_landineq_ctrl_bdei5.clse=coeftest(lm_exp_ext8_an71_landineq_ctrl_bdei5, lm_exp_ext8_an71_landineq_ctrl_bdei5.vcovCL)
lm_exp_ext8_an71_landineq_ctrl_bdei5.clse



###########################
### CONSERVATIVE PARTY VOTE SHARE
###########################

lm_exp_ext8_an71_consvotes_ctrl=lm(votes_cons_share_1871 ~ BDEI_score + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation + as.factor(grid_loc)-1, data=data_analysis_1871_fin_qrSPFE)
summary(lm_exp_ext8_an71_consvotes_ctrl)

lm_exp_ext8_an71_consvotes_ctrl_bdei3=lm(votes_cons_share_1871 ~ BDEI_score3 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation + as.factor(grid_loc)-1, data=data_analysis_1871_fin_qrSPFE)
summary(lm_exp_ext8_an71_consvotes_ctrl_bdei3)

lm_exp_ext8_an71_consvotes_ctrl_bdei5=lm(votes_cons_share_1871 ~ BDEI_score5 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation + as.factor(grid_loc)-1, data=data_analysis_1871_fin_qrSPFE)
summary(lm_exp_ext8_an71_consvotes_ctrl_bdei5)

### CLUSTERED STANDARD ERRORS

lm_exp_ext8_an71_consvotes_ctrl.vcovCL=cluster.vcov(lm_exp_ext8_an71_consvotes_ctrl, data_analysis_1871_fin_qrSPFE$reg_bez)
lm_exp_ext8_an71_consvotes_ctrl.clse=coeftest(lm_exp_ext8_an71_consvotes_ctrl, lm_exp_ext8_an71_consvotes_ctrl.vcovCL)
lm_exp_ext8_an71_consvotes_ctrl.clse

lm_exp_ext8_an71_consvotes_ctrl_bdei3.vcovCL=cluster.vcov(lm_exp_ext8_an71_consvotes_ctrl_bdei3, data_analysis_1871_fin_qrSPFE$reg_bez)
lm_exp_ext8_an71_consvotes_ctrl_bdei3.clse=coeftest(lm_exp_ext8_an71_consvotes_ctrl_bdei3, lm_exp_ext8_an71_consvotes_ctrl_bdei3.vcovCL)
lm_exp_ext8_an71_consvotes_ctrl_bdei3.clse

lm_exp_ext8_an71_consvotes_ctrl_bdei5.vcovCL=cluster.vcov(lm_exp_ext8_an71_consvotes_ctrl_bdei5, data_analysis_1871_fin_qrSPFE$reg_bez)
lm_exp_ext8_an71_consvotes_ctrl_bdei5.clse=coeftest(lm_exp_ext8_an71_consvotes_ctrl_bdei5, lm_exp_ext8_an71_consvotes_ctrl_bdei5.vcovCL)
lm_exp_ext8_an71_consvotes_ctrl_bdei5.clse



###########################
### NET ELECTORAL DISPUTES
###########################

qp_exp_ext8_an71_disputes_ctrl=glm(NetDisputes ~ BDEI_score + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation + as.factor(grid_loc)-1, family=quasipoisson(link = "log"), data=data_analysis_1871_fin_qrSPFE)
summary(qp_exp_ext8_an71_disputes_ctrl)

qp_exp_ext8_an71_disputes_ctrl_bdei3=glm(NetDisputes ~ BDEI_score3 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation + as.factor(grid_loc)-1, family=quasipoisson(link = "log"), data=data_analysis_1871_fin_qrSPFE)
summary(qp_exp_ext8_an71_disputes_ctrl_bdei3)

qp_exp_ext8_an71_disputes_ctrl_bdei5=glm(NetDisputes ~ BDEI_score5 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation + as.factor(grid_loc)-1, family=quasipoisson(link = "log"), data=data_analysis_1871_fin_qrSPFE)
summary(qp_exp_ext8_an71_disputes_ctrl_bdei5)

### CLUSTERED STANDARD ERRORS

qp_exp_ext8_an71_disputes_ctrl.vcovCL=cluster.vcov(qp_exp_ext8_an71_disputes_ctrl, data_analysis_1871_fin_qrSPFE$reg_bez)
qp_exp_ext8_an71_disputes_ctrl.clse=coeftest(qp_exp_ext8_an71_disputes_ctrl, qp_exp_ext8_an71_disputes_ctrl.vcovCL)
qp_exp_ext8_an71_disputes_ctrl.clse

qp_exp_ext8_an71_disputes_ctrl_bdei3.vcovCL=cluster.vcov(qp_exp_ext8_an71_disputes_ctrl_bdei3, data_analysis_1871_fin_qrSPFE$reg_bez)
qp_exp_ext8_an71_disputes_ctrl_bdei3.clse=coeftest(qp_exp_ext8_an71_disputes_ctrl_bdei3, qp_exp_ext8_an71_disputes_ctrl_bdei3.vcovCL)
qp_exp_ext8_an71_disputes_ctrl_bdei3.clse

qp_exp_ext8_an71_disputes_ctrl_bdei5.vcovCL=cluster.vcov(qp_exp_ext8_an71_disputes_ctrl_bdei5, data_analysis_1871_fin_qrSPFE$reg_bez)
qp_exp_ext8_an71_disputes_ctrl_bdei5.clse=coeftest(qp_exp_ext8_an71_disputes_ctrl_bdei5, qp_exp_ext8_an71_disputes_ctrl_bdei5.vcovCL)
qp_exp_ext8_an71_disputes_ctrl_bdei5.clse



###########################
### EXTENSION 9 - USING ALTERNATIVE DATASETS OF PLAGUE OUTBREAKS
### PART 1: DATA BY BUENTGEN ET AL. (2012)
### TABLE A14 IN THE SUPPLEMENTARY MATERIAL
###########################

###########################
### LANDHOLDING INEQUALITY
###########################

lm_exp_ext9_an71_landineq_ctrl=lm(landgini ~ BDEI_score_novel + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext9_an71_landineq_ctrl)

lm_exp_ext9_an71_landineq_ctrl_bdei3=lm(landgini ~ BDEI_score_novel3 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext9_an71_landineq_ctrl_bdei3)

lm_exp_ext9_an71_landineq_ctrl_bdei5=lm(landgini ~ BDEI_score_novel5 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext9_an71_landineq_ctrl_bdei5)

### CLUSTERED STANDARD ERRORS

lm_exp_ext9_an71_landineq_ctrl.vcovCL=cluster.vcov(lm_exp_ext9_an71_landineq_ctrl, data_analysis_1871_fin$reg_bez)
lm_exp_ext9_an71_landineq_ctrl.clse=coeftest(lm_exp_ext9_an71_landineq_ctrl, lm_exp_ext9_an71_landineq_ctrl.vcovCL)
lm_exp_ext9_an71_landineq_ctrl.clse

lm_exp_ext9_an71_landineq_ctrl_bdei3.vcovCL=cluster.vcov(lm_exp_ext9_an71_landineq_ctrl_bdei3, data_analysis_1871_fin$reg_bez)
lm_exp_ext9_an71_landineq_ctrl_bdei3.clse=coeftest(lm_exp_ext9_an71_landineq_ctrl_bdei3, lm_exp_ext9_an71_landineq_ctrl_bdei3.vcovCL)
lm_exp_ext9_an71_landineq_ctrl_bdei3.clse

lm_exp_ext9_an71_landineq_ctrl_bdei5.vcovCL=cluster.vcov(lm_exp_ext9_an71_landineq_ctrl_bdei5, data_analysis_1871_fin$reg_bez)
lm_exp_ext9_an71_landineq_ctrl_bdei5.clse=coeftest(lm_exp_ext9_an71_landineq_ctrl_bdei5, lm_exp_ext9_an71_landineq_ctrl_bdei5.vcovCL)
lm_exp_ext9_an71_landineq_ctrl_bdei5.clse



###########################
### CONSERVATIVE PARTY VOTE SHARE
###########################

lm_exp_ext9_an71_consvotes_ctrl=lm(votes_cons_share_1871 ~ BDEI_score_novel + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext9_an71_consvotes_ctrl)

lm_exp_ext9_an71_consvotes_ctrl_bdei3=lm(votes_cons_share_1871 ~ BDEI_score_novel3 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext9_an71_consvotes_ctrl_bdei3)

lm_exp_ext9_an71_consvotes_ctrl_bdei5=lm(votes_cons_share_1871 ~ BDEI_score_novel5 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext9_an71_consvotes_ctrl_bdei5)

### CLUSTERED STANDARD ERRORS

lm_exp_ext9_an71_consvotes_ctrl.vcovCL=cluster.vcov(lm_exp_ext9_an71_consvotes_ctrl, data_analysis_1871_fin$reg_bez)
lm_exp_ext9_an71_consvotes_ctrl.clse=coeftest(lm_exp_ext9_an71_consvotes_ctrl, lm_exp_ext9_an71_consvotes_ctrl.vcovCL)
lm_exp_ext9_an71_consvotes_ctrl.clse

lm_exp_ext9_an71_consvotes_ctrl_bdei3.vcovCL=cluster.vcov(lm_exp_ext9_an71_consvotes_ctrl_bdei3, data_analysis_1871_fin$reg_bez)
lm_exp_ext9_an71_consvotes_ctrl_bdei3.clse=coeftest(lm_exp_ext9_an71_consvotes_ctrl_bdei3, lm_exp_ext9_an71_consvotes_ctrl_bdei3.vcovCL)
lm_exp_ext9_an71_consvotes_ctrl_bdei3.clse

lm_exp_ext9_an71_consvotes_ctrl_bdei5.vcovCL=cluster.vcov(lm_exp_ext9_an71_consvotes_ctrl_bdei5, data_analysis_1871_fin$reg_bez)
lm_exp_ext9_an71_consvotes_ctrl_bdei5.clse=coeftest(lm_exp_ext9_an71_consvotes_ctrl_bdei5, lm_exp_ext9_an71_consvotes_ctrl_bdei5.vcovCL)
lm_exp_ext9_an71_consvotes_ctrl_bdei5.clse



###########################
### NET ELECTORAL DISPUTES
###########################

qp_exp_ext9_an71_disputes_ctrl=glm(NetDisputes ~ BDEI_score_novel + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, family=quasipoisson(link = "log"), data=data_analysis_1871_fin)
summary(qp_exp_ext9_an71_disputes_ctrl)

qp_exp_ext9_an71_disputes_ctrl_bdei3=glm(NetDisputes ~ BDEI_score_novel3 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, family=quasipoisson(link = "log"), data=data_analysis_1871_fin)
summary(qp_exp_ext9_an71_disputes_ctrl_bdei3)

qp_exp_ext9_an71_disputes_ctrl_bdei5=glm(NetDisputes ~ BDEI_score_novel5 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, family=quasipoisson(link = "log"), data=data_analysis_1871_fin)
summary(qp_exp_ext9_an71_disputes_ctrl_bdei5)

### CLUSTERED STANDARD ERRORS

qp_exp_ext9_an71_disputes_ctrl.vcovCL=cluster.vcov(qp_exp_ext9_an71_disputes_ctrl, data_analysis_1871_fin$reg_bez)
qp_exp_ext9_an71_disputes_ctrl.clse=coeftest(qp_exp_ext9_an71_disputes_ctrl, qp_exp_ext9_an71_disputes_ctrl.vcovCL)
qp_exp_ext9_an71_disputes_ctrl.clse

qp_exp_ext9_an71_disputes_ctrl_bdei3.vcovCL=cluster.vcov(qp_exp_ext9_an71_disputes_ctrl_bdei3, data_analysis_1871_fin$reg_bez)
qp_exp_ext9_an71_disputes_ctrl_bdei3.clse=coeftest(qp_exp_ext9_an71_disputes_ctrl_bdei3, qp_exp_ext9_an71_disputes_ctrl_bdei3.vcovCL)
qp_exp_ext9_an71_disputes_ctrl_bdei3.clse

qp_exp_ext9_an71_disputes_ctrl_bdei5.vcovCL=cluster.vcov(qp_exp_ext9_an71_disputes_ctrl_bdei5, data_analysis_1871_fin$reg_bez)
qp_exp_ext9_an71_disputes_ctrl_bdei5.clse=coeftest(qp_exp_ext9_an71_disputes_ctrl_bdei5, qp_exp_ext9_an71_disputes_ctrl_bdei5.vcovCL)
qp_exp_ext9_an71_disputes_ctrl_bdei5.clse



###########################
### EXTENSION 9 - USING ALTERNATIVE DATASETS OF PLAGUE OUTBREAKS
### PART 2: DATA BY SCHMID ET AL. (2015)
### TABLE A15 IN THE SUPPLEMENTARY MATERIAL
###########################

###########################
### LANDHOLDING INEQUALITY
###########################

lm_exp_ext9a_an71_landineq_ctrl=lm(landgini ~ BDEI_score_newdata + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext9a_an71_landineq_ctrl)

lm_exp_ext9a_an71_landineq_ctrl_bdei3=lm(landgini ~ BDEI_score_newdata3 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext9a_an71_landineq_ctrl_bdei3)

lm_exp_ext9a_an71_landineq_ctrl_bdei5=lm(landgini ~ BDEI_score_newdata5 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext9a_an71_landineq_ctrl_bdei5)

### CLUSTERED STANDARD ERRORS

lm_exp_ext9a_an71_landineq_ctrl.vcovCL=cluster.vcov(lm_exp_ext9a_an71_landineq_ctrl, data_analysis_1871_fin$reg_bez)
lm_exp_ext9a_an71_landineq_ctrl.clse=coeftest(lm_exp_ext9a_an71_landineq_ctrl, lm_exp_ext9a_an71_landineq_ctrl.vcovCL)
lm_exp_ext9a_an71_landineq_ctrl.clse

lm_exp_ext9a_an71_landineq_ctrl_bdei3.vcovCL=cluster.vcov(lm_exp_ext9a_an71_landineq_ctrl_bdei3, data_analysis_1871_fin$reg_bez)
lm_exp_ext9a_an71_landineq_ctrl_bdei3.clse=coeftest(lm_exp_ext9a_an71_landineq_ctrl_bdei3, lm_exp_ext9a_an71_landineq_ctrl_bdei3.vcovCL)
lm_exp_ext9a_an71_landineq_ctrl_bdei3.clse

lm_exp_ext9a_an71_landineq_ctrl_bdei5.vcovCL=cluster.vcov(lm_exp_ext9a_an71_landineq_ctrl_bdei5, data_analysis_1871_fin$reg_bez)
lm_exp_ext9a_an71_landineq_ctrl_bdei5.clse=coeftest(lm_exp_ext9a_an71_landineq_ctrl_bdei5, lm_exp_ext9a_an71_landineq_ctrl_bdei5.vcovCL)
lm_exp_ext9a_an71_landineq_ctrl_bdei5.clse



###########################
### CONSERVATIVE PARTY VOTE SHARE
###########################

lm_exp_ext9a_an71_consvotes_ctrl=lm(votes_cons_share_1871 ~ BDEI_score_newdata + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext9a_an71_consvotes_ctrl)

lm_exp_ext9a_an71_consvotes_ctrl_bdei3=lm(votes_cons_share_1871 ~ BDEI_score_newdata3 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext9a_an71_consvotes_ctrl_bdei3)

lm_exp_ext9a_an71_consvotes_ctrl_bdei5=lm(votes_cons_share_1871 ~ BDEI_score_newdata5 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext9a_an71_consvotes_ctrl_bdei5)

### CLUSTERED STANDARD ERRORS

lm_exp_ext9a_an71_consvotes_ctrl.vcovCL=cluster.vcov(lm_exp_ext9a_an71_consvotes_ctrl, data_analysis_1871_fin$reg_bez)
lm_exp_ext9a_an71_consvotes_ctrl.clse=coeftest(lm_exp_ext9a_an71_consvotes_ctrl, lm_exp_ext9a_an71_consvotes_ctrl.vcovCL)
lm_exp_ext9a_an71_consvotes_ctrl.clse

lm_exp_ext9a_an71_consvotes_ctrl_bdei3.vcovCL=cluster.vcov(lm_exp_ext9a_an71_consvotes_ctrl_bdei3, data_analysis_1871_fin$reg_bez)
lm_exp_ext9a_an71_consvotes_ctrl_bdei3.clse=coeftest(lm_exp_ext9a_an71_consvotes_ctrl_bdei3, lm_exp_ext9a_an71_consvotes_ctrl_bdei3.vcovCL)
lm_exp_ext9a_an71_consvotes_ctrl_bdei3.clse

lm_exp_ext9a_an71_consvotes_ctrl_bdei5.vcovCL=cluster.vcov(lm_exp_ext9a_an71_consvotes_ctrl_bdei5, data_analysis_1871_fin$reg_bez)
lm_exp_ext9a_an71_consvotes_ctrl_bdei5.clse=coeftest(lm_exp_ext9a_an71_consvotes_ctrl_bdei5, lm_exp_ext9a_an71_consvotes_ctrl_bdei5.vcovCL)
lm_exp_ext9a_an71_consvotes_ctrl_bdei5.clse



###########################
### NET ELECTORAL DISPUTES
###########################

qp_exp_ext9a_an71_disputes_ctrl=glm(NetDisputes ~ BDEI_score_newdata + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, family=quasipoisson(link = "log"), data=data_analysis_1871_fin)
summary(qp_exp_ext9a_an71_disputes_ctrl)

qp_exp_ext9a_an71_disputes_ctrl_bdei3=glm(NetDisputes ~ BDEI_score_newdata3 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, family=quasipoisson(link = "log"), data=data_analysis_1871_fin)
summary(qp_exp_ext9a_an71_disputes_ctrl_bdei3)

qp_exp_ext9a_an71_disputes_ctrl_bdei5=glm(NetDisputes ~ BDEI_score_newdata5 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, family=quasipoisson(link = "log"), data=data_analysis_1871_fin)
summary(qp_exp_ext9a_an71_disputes_ctrl_bdei5)

### CLUSTERED STANDARD ERRORS

qp_exp_ext9a_an71_disputes_ctrl.vcovCL=cluster.vcov(qp_exp_ext9a_an71_disputes_ctrl, data_analysis_1871_fin$reg_bez)
qp_exp_ext9a_an71_disputes_ctrl.clse=coeftest(qp_exp_ext9a_an71_disputes_ctrl, qp_exp_ext9a_an71_disputes_ctrl.vcovCL)
qp_exp_ext9a_an71_disputes_ctrl.clse

qp_exp_ext9a_an71_disputes_ctrl_bdei3.vcovCL=cluster.vcov(qp_exp_ext9a_an71_disputes_ctrl_bdei3, data_analysis_1871_fin$reg_bez)
qp_exp_ext9a_an71_disputes_ctrl_bdei3.clse=coeftest(qp_exp_ext9a_an71_disputes_ctrl_bdei3, qp_exp_ext9a_an71_disputes_ctrl_bdei3.vcovCL)
qp_exp_ext9a_an71_disputes_ctrl_bdei3.clse

qp_exp_ext9a_an71_disputes_ctrl_bdei5.vcovCL=cluster.vcov(qp_exp_ext9a_an71_disputes_ctrl_bdei5, data_analysis_1871_fin$reg_bez)
qp_exp_ext9a_an71_disputes_ctrl_bdei5.clse=coeftest(qp_exp_ext9a_an71_disputes_ctrl_bdei5, qp_exp_ext9a_an71_disputes_ctrl_bdei5.vcovCL)
qp_exp_ext9a_an71_disputes_ctrl_bdei5.clse



###########################
### EXTENSION 10 - INTRODUCING PRE-TREATMENT SPATIAL FIXED EFFECTS
### TABLE A16 IN THE SUPPLEMENTARY MATERIAL
###########################

###########################
### LANDHOLDING INEQUALITY
###########################

lm_exp_ext10_an71_landineq_ctrl=lm(landgini ~ BDEI_score + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation + as.factor(short_name)-1, data=data_analysis_1871_fin_pretrSPFE)
summary(lm_exp_ext10_an71_landineq_ctrl)

lm_exp_ext10_an71_landineq_ctrl_bdei3=lm(landgini ~ BDEI_score3 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation + as.factor(short_name)-1, data=data_analysis_1871_fin_pretrSPFE)
summary(lm_exp_ext10_an71_landineq_ctrl_bdei3)

lm_exp_ext10_an71_landineq_ctrl_bdei5=lm(landgini ~ BDEI_score5 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation + as.factor(short_name)-1, data=data_analysis_1871_fin_pretrSPFE)
summary(lm_exp_ext10_an71_landineq_ctrl_bdei5)

### CLUSTERED STANDARD ERRORS

lm_exp_ext10_an71_landineq_ctrl.vcovCL=cluster.vcov(lm_exp_ext10_an71_landineq_ctrl, data_analysis_1871_fin_pretrSPFE$reg_bez)
lm_exp_ext10_an71_landineq_ctrl.clse=coeftest(lm_exp_ext10_an71_landineq_ctrl, lm_exp_ext10_an71_landineq_ctrl.vcovCL)
lm_exp_ext10_an71_landineq_ctrl.clse

lm_exp_ext10_an71_landineq_ctrl_bdei3.vcovCL=cluster.vcov(lm_exp_ext10_an71_landineq_ctrl_bdei3, data_analysis_1871_fin_pretrSPFE$reg_bez)
lm_exp_ext10_an71_landineq_ctrl_bdei3.clse=coeftest(lm_exp_ext10_an71_landineq_ctrl_bdei3, lm_exp_ext10_an71_landineq_ctrl_bdei3.vcovCL)
lm_exp_ext10_an71_landineq_ctrl_bdei3.clse

lm_exp_ext10_an71_landineq_ctrl_bdei5.vcovCL=cluster.vcov(lm_exp_ext10_an71_landineq_ctrl_bdei5, data_analysis_1871_fin_pretrSPFE$reg_bez)
lm_exp_ext10_an71_landineq_ctrl_bdei5.clse=coeftest(lm_exp_ext10_an71_landineq_ctrl_bdei5, lm_exp_ext10_an71_landineq_ctrl_bdei5.vcovCL)
lm_exp_ext10_an71_landineq_ctrl_bdei5.clse



###########################
### CONSERVATIVE PARTY VOTE SHARE
###########################

lm_exp_ext10_an71_consvotes_ctrl=lm(votes_cons_share_1871 ~ BDEI_score + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation + as.factor(short_name)-1, data=data_analysis_1871_fin_pretrSPFE)
summary(lm_exp_ext10_an71_consvotes_ctrl)

lm_exp_ext10_an71_consvotes_ctrl_bdei3=lm(votes_cons_share_1871 ~ BDEI_score3 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation + as.factor(short_name)-1, data=data_analysis_1871_fin_pretrSPFE)
summary(lm_exp_ext10_an71_consvotes_ctrl_bdei3)

lm_exp_ext10_an71_consvotes_ctrl_bdei5=lm(votes_cons_share_1871 ~ BDEI_score5 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation + as.factor(short_name)-1, data=data_analysis_1871_fin_pretrSPFE)
summary(lm_exp_ext10_an71_consvotes_ctrl_bdei5)

### CLUSTERED STANDARD ERRORS

lm_exp_ext10_an71_consvotes_ctrl.vcovCL=cluster.vcov(lm_exp_ext10_an71_consvotes_ctrl, data_analysis_1871_fin_pretrSPFE$reg_bez)
lm_exp_ext10_an71_consvotes_ctrl.clse=coeftest(lm_exp_ext10_an71_consvotes_ctrl, lm_exp_ext10_an71_consvotes_ctrl.vcovCL)
lm_exp_ext10_an71_consvotes_ctrl.clse

lm_exp_ext10_an71_consvotes_ctrl_bdei3.vcovCL=cluster.vcov(lm_exp_ext10_an71_consvotes_ctrl_bdei3, data_analysis_1871_fin_pretrSPFE$reg_bez)
lm_exp_ext10_an71_consvotes_ctrl_bdei3.clse=coeftest(lm_exp_ext10_an71_consvotes_ctrl_bdei3, lm_exp_ext10_an71_consvotes_ctrl_bdei3.vcovCL)
lm_exp_ext10_an71_consvotes_ctrl_bdei3.clse

lm_exp_ext10_an71_consvotes_ctrl_bdei5.vcovCL=cluster.vcov(lm_exp_ext10_an71_consvotes_ctrl_bdei5, data_analysis_1871_fin_pretrSPFE$reg_bez)
lm_exp_ext10_an71_consvotes_ctrl_bdei5.clse=coeftest(lm_exp_ext10_an71_consvotes_ctrl_bdei5, lm_exp_ext10_an71_consvotes_ctrl_bdei5.vcovCL)
lm_exp_ext10_an71_consvotes_ctrl_bdei5.clse



###########################
### NET ELECTORAL DISPUTES
###########################

qp_exp_ext10_an71_disputes_ctrl=glm(NetDisputes ~ BDEI_score + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation + as.factor(short_name)-1, family=quasipoisson(link = "log"), data=data_analysis_1871_fin_pretrSPFE)
summary(qp_exp_ext10_an71_disputes_ctrl)

qp_exp_ext10_an71_disputes_ctrl_bdei3=glm(NetDisputes ~ BDEI_score3 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation + as.factor(short_name)-1, family=quasipoisson(link = "log"), data=data_analysis_1871_fin_pretrSPFE)
summary(qp_exp_ext10_an71_disputes_ctrl_bdei3)

qp_exp_ext10_an71_disputes_ctrl_bdei5=glm(NetDisputes ~ BDEI_score5 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation + as.factor(short_name)-1, family=quasipoisson(link = "log"), data=data_analysis_1871_fin_pretrSPFE)
summary(qp_exp_ext10_an71_disputes_ctrl_bdei5)

### CLUSTERED STANDARD ERRORS

qp_exp_ext10_an71_disputes_ctrl.vcovCL=cluster.vcov(qp_exp_ext10_an71_disputes_ctrl, data_analysis_1871_fin_pretrSPFE$reg_bez)
qp_exp_ext10_an71_disputes_ctrl.clse=coeftest(qp_exp_ext10_an71_disputes_ctrl, qp_exp_ext10_an71_disputes_ctrl.vcovCL)
qp_exp_ext10_an71_disputes_ctrl.clse

qp_exp_ext10_an71_disputes_ctrl_bdei3.vcovCL=cluster.vcov(qp_exp_ext10_an71_disputes_ctrl_bdei3, data_analysis_1871_fin_pretrSPFE$reg_bez)
qp_exp_ext10_an71_disputes_ctrl_bdei3.clse=coeftest(qp_exp_ext10_an71_disputes_ctrl_bdei3, qp_exp_ext10_an71_disputes_ctrl_bdei3.vcovCL)
qp_exp_ext10_an71_disputes_ctrl_bdei3.clse

qp_exp_ext10_an71_disputes_ctrl_bdei5.vcovCL=cluster.vcov(qp_exp_ext10_an71_disputes_ctrl_bdei5, data_analysis_1871_fin_pretrSPFE$reg_bez)
qp_exp_ext10_an71_disputes_ctrl_bdei5.clse=coeftest(qp_exp_ext10_an71_disputes_ctrl_bdei5, qp_exp_ext10_an71_disputes_ctrl_bdei5.vcovCL)
qp_exp_ext10_an71_disputes_ctrl_bdei5.clse



###########################
### EXTENSION 11 - EXTENDING THE ANALYSIS TO OTHER PARTIES AND ELECTIONS
### TABLE A17 IN THE SUPPLEMENTARY MATERIAL
###########################

###########################
### COMBINED VOTE SHARE OF ALL CONSERVATIVE PARTIES (1871)
###########################

lm_exp_ext11_an71_allconsparties_ctrl=lm(votes_multi_share_1871 ~ BDEI_score + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext11_an71_allconsparties_ctrl)

lm_exp_ext11_an71_allconsparties_ctrl_bdei3=lm(votes_multi_share_1871 ~ BDEI_score3 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext11_an71_allconsparties_ctrl_bdei3)

lm_exp_ext11_an71_allconsparties_ctrl_bdei5=lm(votes_multi_share_1871 ~ BDEI_score5 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext11_an71_allconsparties_ctrl_bdei5)

### CLUSTERED STANDARD ERRORS

lm_exp_ext11_an71_allconsparties_ctrl.vcovCL=cluster.vcov(lm_exp_ext11_an71_allconsparties_ctrl, data_analysis_1871_fin$reg_bez)
lm_exp_ext11_an71_allconsparties_ctrl.clse=coeftest(lm_exp_ext11_an71_allconsparties_ctrl, lm_exp_ext11_an71_allconsparties_ctrl.vcovCL)
lm_exp_ext11_an71_allconsparties_ctrl.clse

lm_exp_ext11_an71_allconsparties_ctrl_bdei3.vcovCL=cluster.vcov(lm_exp_ext11_an71_allconsparties_ctrl_bdei3, data_analysis_1871_fin$reg_bez)
lm_exp_ext11_an71_allconsparties_ctrl_bdei3.clse=coeftest(lm_exp_ext11_an71_allconsparties_ctrl_bdei3, lm_exp_ext11_an71_allconsparties_ctrl_bdei3.vcovCL)
lm_exp_ext11_an71_allconsparties_ctrl_bdei3.clse

lm_exp_ext11_an71_allconsparties_ctrl_bdei5.vcovCL=cluster.vcov(lm_exp_ext11_an71_allconsparties_ctrl_bdei5, data_analysis_1871_fin$reg_bez)
lm_exp_ext11_an71_allconsparties_ctrl_bdei5.clse=coeftest(lm_exp_ext11_an71_allconsparties_ctrl_bdei5, lm_exp_ext11_an71_allconsparties_ctrl_bdei5.vcovCL)
lm_exp_ext11_an71_allconsparties_ctrl_bdei5.clse



###########################
### COMBINED VOTE SHARE OF ALL MAJOR LIBERAL AND MODERATE PARTIES (1871)
###########################

lm_exp_ext11_an71_libmodparties_ctrl=lm(votes_lib_share_1871 ~ BDEI_score + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext11_an71_libmodparties_ctrl)

lm_exp_ext11_an71_libmodparties_ctrl_bdei3=lm(votes_lib_share_1871 ~ BDEI_score3 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext11_an71_libmodparties_ctrl_bdei3)

lm_exp_ext11_an71_libmodparties_ctrl_bdei5=lm(votes_lib_share_1871 ~ BDEI_score5 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext11_an71_libmodparties_ctrl_bdei5)

### CLUSTERED STANDARD ERRORS

lm_exp_ext11_an71_libmodparties_ctrl.vcovCL=cluster.vcov(lm_exp_ext11_an71_libmodparties_ctrl, data_analysis_1871_fin$reg_bez)
lm_exp_ext11_an71_libmodparties_ctrl.clse=coeftest(lm_exp_ext11_an71_libmodparties_ctrl, lm_exp_ext11_an71_libmodparties_ctrl.vcovCL)
lm_exp_ext11_an71_libmodparties_ctrl.clse

lm_exp_ext11_an71_libmodparties_ctrl_bdei3.vcovCL=cluster.vcov(lm_exp_ext11_an71_libmodparties_ctrl_bdei3, data_analysis_1871_fin$reg_bez)
lm_exp_ext11_an71_libmodparties_ctrl_bdei3.clse=coeftest(lm_exp_ext11_an71_libmodparties_ctrl_bdei3, lm_exp_ext11_an71_libmodparties_ctrl_bdei3.vcovCL)
lm_exp_ext11_an71_libmodparties_ctrl_bdei3.clse

lm_exp_ext11_an71_libmodparties_ctrl_bdei5.vcovCL=cluster.vcov(lm_exp_ext11_an71_libmodparties_ctrl_bdei5, data_analysis_1871_fin$reg_bez)
lm_exp_ext11_an71_libmodparties_ctrl_bdei5.clse=coeftest(lm_exp_ext11_an71_libmodparties_ctrl_bdei5, lm_exp_ext11_an71_libmodparties_ctrl_bdei5.vcovCL)
lm_exp_ext11_an71_libmodparties_ctrl_bdei5.clse



###########################
### CONSERVATIVE PARTY VOTE SHARE IN THE ELECTION OF 1874
###########################

lm_exp_ext11_an71_consparty1874_ctrl=lm(votes_cons_share_1874 ~ BDEI_score + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext11_an71_consparty1874_ctrl)

lm_exp_ext11_an71_consparty1874_ctrl_bdei3=lm(votes_cons_share_1874 ~ BDEI_score3 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext11_an71_consparty1874_ctrl_bdei3)

lm_exp_ext11_an71_consparty1874_ctrl_bdei5=lm(votes_cons_share_1874 ~ BDEI_score5 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext11_an71_consparty1874_ctrl_bdei5)

### CLUSTERED STANDARD ERRORS

lm_exp_ext11_an71_consparty1874_ctrl.vcovCL=cluster.vcov(lm_exp_ext11_an71_consparty1874_ctrl, data_analysis_1871_fin$reg_bez)
lm_exp_ext11_an71_consparty1874_ctrl.clse=coeftest(lm_exp_ext11_an71_consparty1874_ctrl, lm_exp_ext11_an71_consparty1874_ctrl.vcovCL)
lm_exp_ext11_an71_consparty1874_ctrl.clse

lm_exp_ext11_an71_consparty1874_ctrl_bdei3.vcovCL=cluster.vcov(lm_exp_ext11_an71_consparty1874_ctrl_bdei3, data_analysis_1871_fin$reg_bez)
lm_exp_ext11_an71_consparty1874_ctrl_bdei3.clse=coeftest(lm_exp_ext11_an71_consparty1874_ctrl_bdei3, lm_exp_ext11_an71_consparty1874_ctrl_bdei3.vcovCL)
lm_exp_ext11_an71_consparty1874_ctrl_bdei3.clse

lm_exp_ext11_an71_consparty1874_ctrl_bdei5.vcovCL=cluster.vcov(lm_exp_ext11_an71_consparty1874_ctrl_bdei5, data_analysis_1871_fin$reg_bez)
lm_exp_ext11_an71_consparty1874_ctrl_bdei5.clse=coeftest(lm_exp_ext11_an71_consparty1874_ctrl_bdei5, lm_exp_ext11_an71_consparty1874_ctrl_bdei5.vcovCL)
lm_exp_ext11_an71_consparty1874_ctrl_bdei5.clse



###########################
### EXTENSION 12 - WEIGHTING THE BDEI SCORE BY POPULATION SIZES
### TABLE A18 IN THE SUPPLEMENTARY MATERIAL
###########################

###########################
### LANDHOLDING INEQUALITY
###########################

lm_exp_ext12_an71_landineq_ctrl=lm(landgini ~ BDEI_score_weight + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext12_an71_landineq_ctrl)

lm_exp_ext12_an71_landineq_ctrl_bdei3=lm(landgini ~ BDEI_score_weight3 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext12_an71_landineq_ctrl_bdei3)

lm_exp_ext12_an71_landineq_ctrl_bdei5=lm(landgini ~ BDEI_score_weight5 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext12_an71_landineq_ctrl_bdei5)

### CLUSTERED STANDARD ERRORS

lm_exp_ext12_an71_landineq_ctrl.vcovCL=cluster.vcov(lm_exp_ext12_an71_landineq_ctrl, data_analysis_1871_fin$reg_bez)
lm_exp_ext12_an71_landineq_ctrl.clse=coeftest(lm_exp_ext12_an71_landineq_ctrl, lm_exp_ext12_an71_landineq_ctrl.vcovCL)
lm_exp_ext12_an71_landineq_ctrl.clse

lm_exp_ext12_an71_landineq_ctrl_bdei3.vcovCL=cluster.vcov(lm_exp_ext12_an71_landineq_ctrl_bdei3, data_analysis_1871_fin$reg_bez)
lm_exp_ext12_an71_landineq_ctrl_bdei3.clse=coeftest(lm_exp_ext12_an71_landineq_ctrl_bdei3, lm_exp_ext12_an71_landineq_ctrl_bdei3.vcovCL)
lm_exp_ext12_an71_landineq_ctrl_bdei3.clse

lm_exp_ext12_an71_landineq_ctrl_bdei5.vcovCL=cluster.vcov(lm_exp_ext12_an71_landineq_ctrl_bdei5, data_analysis_1871_fin$reg_bez)
lm_exp_ext12_an71_landineq_ctrl_bdei5.clse=coeftest(lm_exp_ext12_an71_landineq_ctrl_bdei5, lm_exp_ext12_an71_landineq_ctrl_bdei5.vcovCL)
lm_exp_ext12_an71_landineq_ctrl_bdei5.clse



###########################
### CONSERVATIVE PARTY VOTE SHARE
###########################

lm_exp_ext12_an71_consvotes_ctrl=lm(votes_cons_share_1871 ~ BDEI_score_weight + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext12_an71_consvotes_ctrl)

lm_exp_ext12_an71_consvotes_ctrl_bdei3=lm(votes_cons_share_1871 ~ BDEI_score_weight3 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext12_an71_consvotes_ctrl_bdei3)

lm_exp_ext12_an71_consvotes_ctrl_bdei5=lm(votes_cons_share_1871 ~ BDEI_score_weight5 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext12_an71_consvotes_ctrl_bdei5)

### CLUSTERED STANDARD ERRORS

lm_exp_ext12_an71_consvotes_ctrl.vcovCL=cluster.vcov(lm_exp_ext12_an71_consvotes_ctrl, data_analysis_1871_fin$reg_bez)
lm_exp_ext12_an71_consvotes_ctrl.clse=coeftest(lm_exp_ext12_an71_consvotes_ctrl, lm_exp_ext12_an71_consvotes_ctrl.vcovCL)
lm_exp_ext12_an71_consvotes_ctrl.clse

lm_exp_ext12_an71_consvotes_ctrl_bdei3.vcovCL=cluster.vcov(lm_exp_ext12_an71_consvotes_ctrl_bdei3, data_analysis_1871_fin$reg_bez)
lm_exp_ext12_an71_consvotes_ctrl_bdei3.clse=coeftest(lm_exp_ext12_an71_consvotes_ctrl_bdei3, lm_exp_ext12_an71_consvotes_ctrl_bdei3.vcovCL)
lm_exp_ext12_an71_consvotes_ctrl_bdei3.clse

lm_exp_ext12_an71_consvotes_ctrl_bdei5.vcovCL=cluster.vcov(lm_exp_ext12_an71_consvotes_ctrl_bdei5, data_analysis_1871_fin$reg_bez)
lm_exp_ext12_an71_consvotes_ctrl_bdei5.clse=coeftest(lm_exp_ext12_an71_consvotes_ctrl_bdei5, lm_exp_ext12_an71_consvotes_ctrl_bdei5.vcovCL)
lm_exp_ext12_an71_consvotes_ctrl_bdei5.clse



###########################
### NET ELECTORAL DISPUTES
###########################

qp_exp_ext12_an71_disputes_ctrl=glm(NetDisputes ~ BDEI_score_weight + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, family=quasipoisson(link = "log"), data=data_analysis_1871_fin)
summary(qp_exp_ext12_an71_disputes_ctrl)

qp_exp_ext12_an71_disputes_ctrl_bdei3=glm(NetDisputes ~ BDEI_score_weight3 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, family=quasipoisson(link = "log"), data=data_analysis_1871_fin)
summary(qp_exp_ext12_an71_disputes_ctrl_bdei3)

qp_exp_ext12_an71_disputes_ctrl_bdei5=glm(NetDisputes ~ BDEI_score_weight5 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, family=quasipoisson(link = "log"), data=data_analysis_1871_fin)
summary(qp_exp_ext12_an71_disputes_ctrl_bdei5)

### CLUSTERED STANDARD ERRORS

qp_exp_ext12_an71_disputes_ctrl.vcovCL=cluster.vcov(qp_exp_ext12_an71_disputes_ctrl, data_analysis_1871_fin$reg_bez)
qp_exp_ext12_an71_disputes_ctrl.clse=coeftest(qp_exp_ext12_an71_disputes_ctrl, qp_exp_ext12_an71_disputes_ctrl.vcovCL)
qp_exp_ext12_an71_disputes_ctrl.clse

qp_exp_ext12_an71_disputes_ctrl_bdei3.vcovCL=cluster.vcov(qp_exp_ext12_an71_disputes_ctrl_bdei3, data_analysis_1871_fin$reg_bez)
qp_exp_ext12_an71_disputes_ctrl_bdei3.clse=coeftest(qp_exp_ext12_an71_disputes_ctrl_bdei3, qp_exp_ext12_an71_disputes_ctrl_bdei3.vcovCL)
qp_exp_ext12_an71_disputes_ctrl_bdei3.clse

qp_exp_ext12_an71_disputes_ctrl_bdei5.vcovCL=cluster.vcov(qp_exp_ext12_an71_disputes_ctrl_bdei5, data_analysis_1871_fin$reg_bez)
qp_exp_ext12_an71_disputes_ctrl_bdei5.clse=coeftest(qp_exp_ext12_an71_disputes_ctrl_bdei5, qp_exp_ext12_an71_disputes_ctrl_bdei5.vcovCL)
qp_exp_ext12_an71_disputes_ctrl_bdei5.clse



###########################
### EXTENSION 13 - CONSIDERING ONLY NEIGHBORING REGIONS IN COMPUTING THE BDEI SCORE
### TABLE A19 IN THE SUPPLEMENTARY MATERIAL
###########################

###########################
### LANDHOLDING INEQUALITY
###########################

lm_exp_ext13_an71_landineq_ctrl=lm(landgini ~ BDEI_score_neighb + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext13_an71_landineq_ctrl)

lm_exp_ext13_an71_landineq_ctrl_bdei3=lm(landgini ~ BDEI_score_neighb3 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext13_an71_landineq_ctrl_bdei3)

lm_exp_ext13_an71_landineq_ctrl_bdei5=lm(landgini ~ BDEI_score_neighb5 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext13_an71_landineq_ctrl_bdei5)

### CLUSTERED STANDARD ERRORS

lm_exp_ext13_an71_landineq_ctrl.vcovCL=cluster.vcov(lm_exp_ext13_an71_landineq_ctrl, data_analysis_1871_fin$reg_bez)
lm_exp_ext13_an71_landineq_ctrl.clse=coeftest(lm_exp_ext13_an71_landineq_ctrl, lm_exp_ext13_an71_landineq_ctrl.vcovCL)
lm_exp_ext13_an71_landineq_ctrl.clse

lm_exp_ext13_an71_landineq_ctrl_bdei3.vcovCL=cluster.vcov(lm_exp_ext13_an71_landineq_ctrl_bdei3, data_analysis_1871_fin$reg_bez)
lm_exp_ext13_an71_landineq_ctrl_bdei3.clse=coeftest(lm_exp_ext13_an71_landineq_ctrl_bdei3, lm_exp_ext13_an71_landineq_ctrl_bdei3.vcovCL)
lm_exp_ext13_an71_landineq_ctrl_bdei3.clse

lm_exp_ext13_an71_landineq_ctrl_bdei5.vcovCL=cluster.vcov(lm_exp_ext13_an71_landineq_ctrl_bdei5, data_analysis_1871_fin$reg_bez)
lm_exp_ext13_an71_landineq_ctrl_bdei5.clse=coeftest(lm_exp_ext13_an71_landineq_ctrl_bdei5, lm_exp_ext13_an71_landineq_ctrl_bdei5.vcovCL)
lm_exp_ext13_an71_landineq_ctrl_bdei5.clse



###########################
### CONSERVATIVE PARTY VOTE SHARE
###########################

lm_exp_ext13_an71_consvotes_ctrl=lm(votes_cons_share_1871 ~ BDEI_score_neighb + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext13_an71_consvotes_ctrl)

lm_exp_ext13_an71_consvotes_ctrl_bdei3=lm(votes_cons_share_1871 ~ BDEI_score_neighb3 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext13_an71_consvotes_ctrl_bdei3)

lm_exp_ext13_an71_consvotes_ctrl_bdei5=lm(votes_cons_share_1871 ~ BDEI_score_neighb5 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext13_an71_consvotes_ctrl_bdei5)

### CLUSTERED STANDARD ERRORS

lm_exp_ext13_an71_consvotes_ctrl.vcovCL=cluster.vcov(lm_exp_ext13_an71_consvotes_ctrl, data_analysis_1871_fin$reg_bez)
lm_exp_ext13_an71_consvotes_ctrl.clse=coeftest(lm_exp_ext13_an71_consvotes_ctrl, lm_exp_ext13_an71_consvotes_ctrl.vcovCL)
lm_exp_ext13_an71_consvotes_ctrl.clse

lm_exp_ext13_an71_consvotes_ctrl_bdei3.vcovCL=cluster.vcov(lm_exp_ext13_an71_consvotes_ctrl_bdei3, data_analysis_1871_fin$reg_bez)
lm_exp_ext13_an71_consvotes_ctrl_bdei3.clse=coeftest(lm_exp_ext13_an71_consvotes_ctrl_bdei3, lm_exp_ext13_an71_consvotes_ctrl_bdei3.vcovCL)
lm_exp_ext13_an71_consvotes_ctrl_bdei3.clse

lm_exp_ext13_an71_consvotes_ctrl_bdei5.vcovCL=cluster.vcov(lm_exp_ext13_an71_consvotes_ctrl_bdei5, data_analysis_1871_fin$reg_bez)
lm_exp_ext13_an71_consvotes_ctrl_bdei5.clse=coeftest(lm_exp_ext13_an71_consvotes_ctrl_bdei5, lm_exp_ext13_an71_consvotes_ctrl_bdei5.vcovCL)
lm_exp_ext13_an71_consvotes_ctrl_bdei5.clse



###########################
### NET ELECTORAL DISPUTES
###########################

qp_exp_ext13_an71_disputes_ctrl=glm(NetDisputes ~ BDEI_score_neighb + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, family=quasipoisson(link = "log"), data=data_analysis_1871_fin)
summary(qp_exp_ext13_an71_disputes_ctrl)

qp_exp_ext13_an71_disputes_ctrl_bdei3=glm(NetDisputes ~ BDEI_score_neighb3 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, family=quasipoisson(link = "log"), data=data_analysis_1871_fin)
summary(qp_exp_ext13_an71_disputes_ctrl_bdei3)

qp_exp_ext13_an71_disputes_ctrl_bdei5=glm(NetDisputes ~ BDEI_score_neighb5 + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, family=quasipoisson(link = "log"), data=data_analysis_1871_fin)
summary(qp_exp_ext13_an71_disputes_ctrl_bdei5)

### CLUSTERED STANDARD ERRORS

qp_exp_ext13_an71_disputes_ctrl.vcovCL=cluster.vcov(qp_exp_ext13_an71_disputes_ctrl, data_analysis_1871_fin$reg_bez)
qp_exp_ext13_an71_disputes_ctrl.clse=coeftest(qp_exp_ext13_an71_disputes_ctrl, qp_exp_ext13_an71_disputes_ctrl.vcovCL)
qp_exp_ext13_an71_disputes_ctrl.clse

qp_exp_ext13_an71_disputes_ctrl_bdei3.vcovCL=cluster.vcov(qp_exp_ext13_an71_disputes_ctrl_bdei3, data_analysis_1871_fin$reg_bez)
qp_exp_ext13_an71_disputes_ctrl_bdei3.clse=coeftest(qp_exp_ext13_an71_disputes_ctrl_bdei3, qp_exp_ext13_an71_disputes_ctrl_bdei3.vcovCL)
qp_exp_ext13_an71_disputes_ctrl_bdei3.clse

qp_exp_ext13_an71_disputes_ctrl_bdei5.vcovCL=cluster.vcov(qp_exp_ext13_an71_disputes_ctrl_bdei5, data_analysis_1871_fin$reg_bez)
qp_exp_ext13_an71_disputes_ctrl_bdei5.clse=coeftest(qp_exp_ext13_an71_disputes_ctrl_bdei5, qp_exp_ext13_an71_disputes_ctrl_bdei5.vcovCL)
qp_exp_ext13_an71_disputes_ctrl_bdei5.clse



###########################
### EXTENSION 14 - ACCOUNTING FOR AGRICULTURAL (CALORIC) POTENTIAL
### TABLE A20 IN THE SUPPLEMENTARY MATERIAL
###########################

###########################
### LANDHOLDING INEQUALITY
###########################

lm_exp_ext14_an71_landineq_ctrl=lm(landgini ~ BDEI_score + cal_potential + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext14_an71_landineq_ctrl)

lm_exp_ext14_an71_landineq_ctrl_bdei3=lm(landgini ~ BDEI_score3 + cal_potential + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext14_an71_landineq_ctrl_bdei3)

lm_exp_ext14_an71_landineq_ctrl_bdei5=lm(landgini ~ BDEI_score5 + cal_potential + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext14_an71_landineq_ctrl_bdei5)

### CLUSTERED STANDARD ERRORS

lm_exp_ext14_an71_landineq_ctrl.vcovCL=cluster.vcov(lm_exp_ext14_an71_landineq_ctrl, data_analysis_1871_fin$reg_bez)
lm_exp_ext14_an71_landineq_ctrl.clse=coeftest(lm_exp_ext14_an71_landineq_ctrl, lm_exp_ext14_an71_landineq_ctrl.vcovCL)
lm_exp_ext14_an71_landineq_ctrl.clse

lm_exp_ext14_an71_landineq_ctrl_bdei3.vcovCL=cluster.vcov(lm_exp_ext14_an71_landineq_ctrl_bdei3, data_analysis_1871_fin$reg_bez)
lm_exp_ext14_an71_landineq_ctrl_bdei3.clse=coeftest(lm_exp_ext14_an71_landineq_ctrl_bdei3, lm_exp_ext14_an71_landineq_ctrl_bdei3.vcovCL)
lm_exp_ext14_an71_landineq_ctrl_bdei3.clse

lm_exp_ext14_an71_landineq_ctrl_bdei5.vcovCL=cluster.vcov(lm_exp_ext14_an71_landineq_ctrl_bdei5, data_analysis_1871_fin$reg_bez)
lm_exp_ext14_an71_landineq_ctrl_bdei5.clse=coeftest(lm_exp_ext14_an71_landineq_ctrl_bdei5, lm_exp_ext14_an71_landineq_ctrl_bdei5.vcovCL)
lm_exp_ext14_an71_landineq_ctrl_bdei5.clse



###########################
### CONSERVATIVE PARTY VOTE SHARE
###########################

lm_exp_ext14_an71_consvotes_ctrl=lm(votes_cons_share_1871 ~ BDEI_score + cal_potential + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext14_an71_consvotes_ctrl)

lm_exp_ext14_an71_consvotes_ctrl_bdei3=lm(votes_cons_share_1871 ~ BDEI_score3 + cal_potential + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext14_an71_consvotes_ctrl_bdei3)

lm_exp_ext14_an71_consvotes_ctrl_bdei5=lm(votes_cons_share_1871 ~ BDEI_score5 + cal_potential + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, data=data_analysis_1871_fin)
summary(lm_exp_ext14_an71_consvotes_ctrl_bdei5)

### CLUSTERED STANDARD ERRORS

lm_exp_ext14_an71_consvotes_ctrl.vcovCL=cluster.vcov(lm_exp_ext14_an71_consvotes_ctrl, data_analysis_1871_fin$reg_bez)
lm_exp_ext14_an71_consvotes_ctrl.clse=coeftest(lm_exp_ext14_an71_consvotes_ctrl, lm_exp_ext14_an71_consvotes_ctrl.vcovCL)
lm_exp_ext14_an71_consvotes_ctrl.clse

lm_exp_ext14_an71_consvotes_ctrl_bdei3.vcovCL=cluster.vcov(lm_exp_ext14_an71_consvotes_ctrl_bdei3, data_analysis_1871_fin$reg_bez)
lm_exp_ext14_an71_consvotes_ctrl_bdei3.clse=coeftest(lm_exp_ext14_an71_consvotes_ctrl_bdei3, lm_exp_ext14_an71_consvotes_ctrl_bdei3.vcovCL)
lm_exp_ext14_an71_consvotes_ctrl_bdei3.clse

lm_exp_ext14_an71_consvotes_ctrl_bdei5.vcovCL=cluster.vcov(lm_exp_ext14_an71_consvotes_ctrl_bdei5, data_analysis_1871_fin$reg_bez)
lm_exp_ext14_an71_consvotes_ctrl_bdei5.clse=coeftest(lm_exp_ext14_an71_consvotes_ctrl_bdei5, lm_exp_ext14_an71_consvotes_ctrl_bdei5.vcovCL)
lm_exp_ext14_an71_consvotes_ctrl_bdei5.clse



###########################
### NET ELECTORAL DISPUTES
###########################

qp_exp_ext14_an71_disputes_ctrl=glm(NetDisputes ~ BDEI_score + cal_potential + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, family=quasipoisson(link = "log"), data=data_analysis_1871_fin)
summary(qp_exp_ext14_an71_disputes_ctrl)

qp_exp_ext14_an71_disputes_ctrl_bdei3=glm(NetDisputes ~ BDEI_score3 + cal_potential + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, family=quasipoisson(link = "log"), data=data_analysis_1871_fin)
summary(qp_exp_ext14_an71_disputes_ctrl_bdei3)

qp_exp_ext14_an71_disputes_ctrl_bdei5=glm(NetDisputes ~ BDEI_score5 + cal_potential + urban_density_norm + dist_majport_km + dist_tradecity_km + dist_ocean_km + dist_river_km + elevation, family=quasipoisson(link = "log"), data=data_analysis_1871_fin)
summary(qp_exp_ext14_an71_disputes_ctrl_bdei5)

### CLUSTERED STANDARD ERRORS

qp_exp_ext14_an71_disputes_ctrl.vcovCL=cluster.vcov(qp_exp_ext14_an71_disputes_ctrl, data_analysis_1871_fin$reg_bez)
qp_exp_ext14_an71_disputes_ctrl.clse=coeftest(qp_exp_ext14_an71_disputes_ctrl, qp_exp_ext14_an71_disputes_ctrl.vcovCL)
qp_exp_ext14_an71_disputes_ctrl.clse

qp_exp_ext14_an71_disputes_ctrl_bdei3.vcovCL=cluster.vcov(qp_exp_ext14_an71_disputes_ctrl_bdei3, data_analysis_1871_fin$reg_bez)
qp_exp_ext14_an71_disputes_ctrl_bdei3.clse=coeftest(qp_exp_ext14_an71_disputes_ctrl_bdei3, qp_exp_ext14_an71_disputes_ctrl_bdei3.vcovCL)
qp_exp_ext14_an71_disputes_ctrl_bdei3.clse

qp_exp_ext14_an71_disputes_ctrl_bdei5.vcovCL=cluster.vcov(qp_exp_ext14_an71_disputes_ctrl_bdei5, data_analysis_1871_fin$reg_bez)
qp_exp_ext14_an71_disputes_ctrl_bdei5.clse=coeftest(qp_exp_ext14_an71_disputes_ctrl_bdei5, qp_exp_ext14_an71_disputes_ctrl_bdei5.vcovCL)
qp_exp_ext14_an71_disputes_ctrl_bdei5.clse


